A library that provides standardised logging for node applications
npm install @mediamonks-ea/node-loggerThis is Typescript based library that provides a standardised interface for logging in NodeJS based applications.
It currently comes with 2 built in loggers:
``bash`
npm install @mediamonks-ea/nodejs-logger
typescript
import { ConsoleLogger, LoggingLevel } from '@mediamonks-ea/nodejs-logger'const logger = new ConsoleLogger('example-logger', LoggingLevel.info, {
enableLabels: true
})
logger.info(
This message will be logged when the logger level is set to info)
logger.debug(
This message will not be logged when the logger level is set to info
)
`
$3
`typescript
import { ILogger, LoggingLevel } from '@mediamonks-ea/nodejs-logger'export class FileLogger implements ILogger {
debug(message: any, labels?: { [p: string]: string }): void {
// ...
}
error(message: any, labels?: { [p: string]: string }): void {
// ...
}
fatal(message: any, labels?: { [p: string]: string }): void {
// ...
}
info(message: any, labels?: { [p: string]: string }): void {
// ...
}
setLabels(labels: { [p: string]: string }): void {
// ...
}
setLoggingLevel(level: LoggingLevel): void {
// ...
}
trace(message: any, labels?: { [p: string]: string }): void {
// ...
}
warn(message: any, labels?: { [p: string]: string }): void {
// ...
}
}
``