Constructor
# new WinstonLogger(cont, confopt, transportsopt)
WinstonLogger extends MiniLogger to provide logging functionality using the Winston library. It configures Winston with appropriate transports and formats based on the logging configuration.
A logger implementation using Winston
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cont |
string
|
The context (typically class name) this logger is associated with |
|
conf |
Partial.<LoggingConfig>
|
<optional> |
Optional configuration to override global settings |
transports |
Array.<Transport>
|
Transport
|
<optional> |
Winston transports to use for logging |
Example
// Create a Winston logger for a class
const logger = new WinstonLogger('MyClass');
// Log messages at different levels
logger.info('Application started');
logger.error(new Error('Something went wrong'));
// Create a child logger for a specific method
const methodLogger = logger.for('myMethod');
methodLogger.debug('Processing data...');
Methods
# protected log(level, msg, stackopt) → {void}
Overrides the base log method to use Winston for logging
Logs a message with the specified log level using Winston
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
level |
LogLevel
|
The log level of the message |
|
msg |
StringLike
|
Error
|
The message to be logged or an Error object |
|
stack |
string
|
<optional> |
Optional stack trace to include in the log |
void