mirror of
https://github.com/denoland/std.git
synced 2024-11-21 12:40:03 +00:00
docs(log): improve logger.ts docs (#6176)
This commit is contained in:
parent
63fdf8d090
commit
bf0ad522e8
@ -82,6 +82,7 @@ const ENTRY_POINTS = [
|
||||
"../log/console_handler.ts",
|
||||
"../log/formatters.ts",
|
||||
"../log/get_logger.ts",
|
||||
"../log/logger.ts",
|
||||
"../media_types/mod.ts",
|
||||
"../msgpack/mod.ts",
|
||||
"../net/mod.ts",
|
||||
|
@ -22,15 +22,98 @@ export interface LogRecordOptions {
|
||||
loggerName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options for a logger instance.
|
||||
*
|
||||
* @example Usage
|
||||
*
|
||||
* ```ts
|
||||
* import { ConsoleHandler, getLogger, setup, type LogConfig} from "@std/log";
|
||||
* import { assert } from "@std/assert";
|
||||
*
|
||||
* const handler = new ConsoleHandler("INFO");
|
||||
* const logConfig: LogConfig = {
|
||||
* handlers: {
|
||||
* default: handler,
|
||||
* },
|
||||
* loggers: {
|
||||
* default: {
|
||||
* level: "INFO",
|
||||
* handlers: ["default"],
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* setup(logConfig);
|
||||
* const logger = getLogger();
|
||||
*
|
||||
* assert(logger.handlers.at(0) instanceof ConsoleHandler);
|
||||
* ```
|
||||
*/
|
||||
export class LoggerConfig {
|
||||
/** The minimum log level for the logger.
|
||||
*
|
||||
* @example Usage
|
||||
*
|
||||
* ```ts
|
||||
* import { ConsoleHandler, getLogger, setup, type LogConfig} from "@std/log";
|
||||
* import { assert } from "@std/assert";
|
||||
*
|
||||
* const handler = new ConsoleHandler("INFO");
|
||||
* const logConfig: LogConfig = {
|
||||
* handlers: {
|
||||
* default: handler,
|
||||
* },
|
||||
* loggers: {
|
||||
* default: {
|
||||
* level: "INFO",
|
||||
* handlers: ["default"],
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* setup(logConfig);
|
||||
* const logger = getLogger();
|
||||
*
|
||||
* assert(logger.handlers.at(0) instanceof ConsoleHandler);
|
||||
* ```
|
||||
*/
|
||||
level?: LevelName;
|
||||
/** A list of handler names attached to this logger.
|
||||
*
|
||||
* @example Usage
|
||||
*
|
||||
* ```ts
|
||||
* import { ConsoleHandler, getLogger, setup, type LogConfig} from "@std/log";
|
||||
* import { assert } from "@std/assert";
|
||||
*
|
||||
* const handler = new ConsoleHandler("INFO");
|
||||
* const logConfig: LogConfig = {
|
||||
* handlers: {
|
||||
* default: handler,
|
||||
* },
|
||||
* loggers: {
|
||||
* default: {
|
||||
* level: "INFO",
|
||||
* handlers: ["default"],
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* setup(logConfig);
|
||||
* const logger = getLogger();
|
||||
*
|
||||
* assert(logger.handlers.at(0) instanceof ConsoleHandler);
|
||||
* ``` */
|
||||
handlers?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for logger setup.
|
||||
*/
|
||||
export interface LogConfig {
|
||||
/** A dictionary of named handlers for logging. */
|
||||
handlers?: {
|
||||
[name: string]: BaseHandler;
|
||||
};
|
||||
/** A dictionary of named loggers and their configurations. */
|
||||
loggers?: {
|
||||
[name: string]: LoggerConfig;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user