KuzzleLogger #
The Node logger. In a Kuzzle application, app.log is a KuzzleLogger.
import { KuzzleLogger } from 'kuzzle-logger';Constructor #
constructor(config: KuzzleLoggerConfig)Parameters #
config: Configuration object (see KuzzleLoggerConfig)
Properties #
level #
get level(): string
set level(level: string)Get or set the current logging level. Valid levels are:
'fatal''error''warn''info''debug''trace''silent'(nothing is logged)
pino #
get pino(): LoggerGet the underlying Pino logger instance.
Methods #
Logging Methods #
All logging methods share similar signatures:
method(obj: object, msg?: string, ...args: any[]): void
method(obj: unknown, msg?: string, ...args: any[]): void
method(msg: string, ...args: any[]): voidtrace(): Log at trace leveldebug(): Log at debug levelinfo(): Log at info levelwarn(): Log at warn levelerror(): Log at error levelfatal(): Log at fatal level
Each method can be called in multiple ways:
- With an object and optional message:
logger.info({ user: 'john' }, 'User logged in'); - With just a message:
logger.info('System started'); - With an error object:
logger.error(new Error('Connection failed'));
flush() #
async flush(): Promise<void>Writes the buffered entries to their destination. For example, call it before the process exits so that the last entries are not lost.
child(namespace: string) #
child(namespace: string): KuzzleLoggerCreates a child logger with the specified namespace. The child logger inherits all settings from its parent and adds the namespace to the merging object. Its level follows the parent level, even when the parent level changes after the child is created, until a level is set on the child itself.