Class Logger
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
- new
Logger (loggerName, levelName, options?): Logger Constructs a new instance.
Parameters
- loggerName: string
The name of the logger.
- levelName: LevelName
The name of the log level.
- options: LoggerOptions = {}
The options to create a new logger.
Returns Logger
- loggerName: string
Properties
handlers
The handlers to use for the logger.
Example: Usage
import { Logger } from "@std/log/logger";
import { ConsoleHandler } from "@std/log/console-handler";
import { assertEquals } from "@std/assert/equals";
const handler = new ConsoleHandler("INFO");
const logger = new Logger("example", "INFO", {
handlers: [handler],
});
assertEquals(logger.handlers, [handler]);
Accessors
level
levelName
loggerName
- get loggerName(): string
Getter for the name of the logger.
Returns string
The name of the logger.
Methods
critical
- critical<T>(msg, ...args): undefined | T
Log at the critical level.
Type Parameters
Parameters
Returns undefined | T
The message that was logged.
- critical<T>(msg, ...args): T
Log at the critical level.
Type Parameters
Parameters
- msg: T extends GenericFunction
? never
: TThe message to log.
Rest...args: unknown[]Arguments to be formatted into the message.
Returns T
The message that was logged.
- msg: T extends GenericFunction
debug
- debug<T>(msg, ...args): undefined | T
Log at the debug level.
Type Parameters
Parameters
Returns undefined | T
The message that was logged.
- debug<T>(msg, ...args): T
Log at the debug level.
Type Parameters
Parameters
- msg: T extends GenericFunction
? never
: TThe message to log.
Rest...args: unknown[]Arguments to be formatted into the message.
Returns T
The message that was logged.
- msg: T extends GenericFunction
error
- error<T>(msg, ...args): undefined | T
Log at the error level.
Type Parameters
Parameters
Returns undefined | T
The message that was logged.
- error<T>(msg, ...args): T
Log at the error level.
Type Parameters
Parameters
- msg: T extends GenericFunction
? never
: TThe message to log.
Rest...args: unknown[]Arguments to be formatted into the message.
Returns T
The message that was logged.
- msg: T extends GenericFunction
info
- info<T>(msg, ...args): undefined | T
Log at the info level.
Type Parameters
Parameters
Returns undefined | T
The message that was logged.
- info<T>(msg, ...args): T
Log at the info level.
Type Parameters
Parameters
- msg: T extends GenericFunction
? never
: TThe message to log.
Rest...args: unknown[]Arguments to be formatted into the message.
Returns T
The message that was logged.
- msg: T extends GenericFunction
warn
- warn<T>(msg, ...args): undefined | T
Log at the warning level.
Type Parameters
Parameters
Returns undefined | T
The message that was logged.
- warn<T>(msg, ...args): T
Log at the warning level.
Type Parameters
Parameters
- msg: T extends GenericFunction
? never
: TThe message to log.
Rest...args: unknown[]Arguments to be formatted into the message.
Returns T
The message that was logged.
- msg: T extends GenericFunction
A logger that can log messages at different levels.
Example: Usage