XYLabs Logger Library
npm install @xylabs/logger[![logo][]](https://xylabs.com)
[![main-build][]][main-build-link]
[![npm-badge][]][npm-link]
[![npm-downloads-badge][]][npm-link]
[![jsdelivr-badge][]][jsdelivr-link]
[![npm-license-badge][]](LICENSE)
[![codacy-badge][]][codacy-link]
[![codeclimate-badge][]][codeclimate-link]
[![snyk-badge][]][snyk-link]
[![socket-badge][]][socket-link]
XYLabs Logger Library
@xylabs/logger
*
- ConsoleLogger
- IdLogger
- LevelLogger
- SilentLogger
- Logger
- LogFunction
- ~~LogLevel~~
- LogLevelKey
- LogVerbosity
- LogLevelValue
- LogLevel
- NoOpLogFunction
- getFunctionName
*
Interface to handle overlap between Winston &console with as much congruency as possible.
``ts`
new ConsoleLogger(level): ConsoleLogger;
#### level
LogLevelValue = LogLevel.warn
ConsoleLogger
`ts`
readonly level: LogLevelValue;
*
`ts`
readonly logger: Logger;
`ts`
get debug(): LogFunction;
#### Returns
*
`ts`
get error(): LogFunction;
#### Returns
*
`ts`
get info(): LogFunction;
#### Returns
*
`ts`
get log(): LogFunction;
#### Returns
*
`ts`
get trace(): LogFunction;
#### Returns
*
`ts`
get warn(): LogFunction;
#### Returns
*
Interface to handle overlap between Winston &
console with as much congruency as possible.
- Logger
`ts`
new IdLogger(logger, id?): IdLogger;
#### logger
#### id?
() => string
IdLogger
`ts`
set id(id): void;
#### Parameters
##### id
string
#### Returns
void
`ts`
debug(...data): void;
#### data
...unknown[]
void
`ts`
Logger.debug
*
`ts`
error(...data): void;
#### data
...unknown[]
void
`ts`
Logger.error
*
`ts`
info(...data): void;
#### data
...unknown[]
void
`ts`
Logger.info
*
`ts`
log(...data): void;
#### data
...unknown[]
void
`ts`
Logger.log
*
`ts`
trace(...data): void;
#### data
...unknown[]
void
`ts`
Logger.trace
*
`ts`
warn(...data): void;
#### data
...unknown[]
void
`ts`
Logger.warn
*
Interface to handle overlap between Winston &
console with as much congruency as possible.
- Logger
`ts`
new LevelLogger(logger, level): LevelLogger;
#### logger
#### level
LogLevelValue = LogLevel.warn
LevelLogger
`ts`
readonly level: LogLevelValue;
*
`ts`
readonly logger: Logger;
`ts`
get debug(): LogFunction;
#### Returns
*
`ts`
get error(): LogFunction;
#### Returns
*
`ts`
get info(): LogFunction;
#### Returns
*
`ts`
get log(): LogFunction;
#### Returns
*
`ts`
get trace(): LogFunction;
#### Returns
*
`ts`
get warn(): LogFunction;
#### Returns
*
A logger that does not log anything.
This is useful when you want to disable logging
like when running unit tests or in silent mode.
It implements the Logger interface but all methods
are no-op functions.
- Logger
`ts`
new SilentLogger(): SilentLogger;
SilentLogger
`ts`
readonly debug: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
readonly error: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
readonly info: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
readonly log: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
readonly trace: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
readonly warn: (..._data) => undefined = NoOpLogFunction;
#### \_data
...unknown[]
undefined
*
`ts`
function NoOpLogFunction(..._data): undefined;
...unknown[]
undefined
*
`ts`
function getFunctionName(depth): string;
number = 2
string
*
Interface to handle overlap between Winston &
console with as much congruency as possible.
`ts`
debug: LogFunction;
*
`ts`
error: LogFunction;
*
`ts`
info: LogFunction;
*
`ts`
log: LogFunction;
*
`ts`
trace: LogFunction;
*
`ts`
warn: LogFunction;
*
`ts`
type LogFunction = (...data) => void;
...unknown[]
void
*
`ts`
type LogLevel = LogLevelValue;
Use LogLevelValue instead.LogLevel
This name conflicts with the enum and
makes it confusing to import
*
`ts`
type LogLevelKey = EnumKey
*
`ts`
type LogLevelValue = EnumValue
*
`ts`
type LogVerbosity = LogLevelKey;
*
`ts``
const LogLevel: Enum<{
error: 1;
warn: 2;
info: 3;
log: 4;
debug: 5;
trace: 6;
}>;
Part of sdk-js
- Arie Trouw (arietrouw.com)
- Matt Jones
- Joel Carter
- Jordan Trouw
> See the LICENSE file for license details
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
[npm-badge]: https://img.shields.io/npm/v/@xylabs/logger.svg
[npm-link]: https://www.npmjs.com/package/@xylabs/logger
[codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698
[codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/logger
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/logger
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/logger/badge
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/logger
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/logger
[socket-link]: https://socket.dev/npm/package/@xylabs/logger