Constructor
# new WinstonLogger(contopt, confopt)
This class extends MiniLogger to provide logging functionality using the Winston library. It configures Winston with the appropriate transports and formats based on the logging configuration.
A logger implementation that uses Winston.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cont |
string
|
<optional> |
The context (typically the class name) that this logger is associated with. |
conf |
Partial.<LoggingConfig>
|
<optional> |
Optional configuration to override global settings. |
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, erroropt) → {void}
This method 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. |
|
error |
Error
|
<optional> |
An optional stack trace to include in the log. |
void