@kosko/log
Advanced tools
Comparing version 0.0.0-20240324064444 to 0.0.0-20240324074257
/** | ||
* Logging library. | ||
* @public | ||
*/ | ||
declare enum LogLevel { | ||
Trace = 1, | ||
Debug = 2, | ||
Info = 3, | ||
Warn = 4, | ||
Error = 5, | ||
Fatal = 6 | ||
} | ||
/** | ||
* @public | ||
*/ | ||
declare function logLevelFromString(level: string): LogLevel | undefined; | ||
/** | ||
* @public | ||
*/ | ||
interface Log { | ||
loggerLevel: LogLevel; | ||
level: LogLevel; | ||
time: Date; | ||
message?: string; | ||
error?: unknown; | ||
data?: unknown; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
interface LogWriter { | ||
write(log: Log): void; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
interface LoggerOptions { | ||
level?: LogLevel; | ||
writer?: LogWriter; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
declare class Logger { | ||
private level; | ||
private writer; | ||
constructor(options: Required<LoggerOptions>); | ||
/** | ||
* @example | ||
* Basic message | ||
* ```ts | ||
* logger.log(LogLevel.Info, "basic message"); | ||
* ``` | ||
* | ||
* @example | ||
* Error | ||
* ```ts | ||
* logger.log(LogLevel.Error, "error log", { | ||
* error: new Error("error cause") | ||
* }); | ||
* ``` | ||
* | ||
* @example | ||
* Data | ||
* ```ts | ||
* logger.log(LogLevel.Info, "log with data", { | ||
* data: { | ||
* foo: "bar" | ||
* } | ||
* }); | ||
* ``` | ||
*/ | ||
log(level: LogLevel, message: string, options?: Partial<Omit<Log, "level" | "message" | "loggerLevel">>): void; | ||
/** | ||
* Returns logger level. | ||
*/ | ||
getLevel(): LogLevel; | ||
/** | ||
* Sets logger level. | ||
*/ | ||
setLevel(level: LogLevel): void; | ||
/** | ||
* Returns true if the given `level` is enabled in logger. | ||
*/ | ||
enabled(level: LogLevel): boolean; | ||
/** | ||
* Returns writer of logger. | ||
*/ | ||
getWriter(): LogWriter; | ||
/** | ||
* Sets writer of logger. | ||
*/ | ||
setWriter(writer: LogWriter): void; | ||
} | ||
/** | ||
* Prints logs to console. | ||
* | ||
* @packageDocumentation | ||
* @public | ||
*/ | ||
export * from "./types"; | ||
export { default as ConsoleLogWriter } from "./ConsoleLogWriter"; | ||
export { default as SilentLogWriter } from "./SilentLogWriter"; | ||
export { LogLevel, logLevelFromString } from "./LogLevel"; | ||
export { default as Logger, type LoggerOptions } from "./Logger"; | ||
export { createLogger } from "./createLogger"; | ||
declare const _default: import("./Logger").default; | ||
export default _default; | ||
declare class ConsoleLogWriter implements LogWriter { | ||
write(log: Log): void; | ||
} | ||
/** | ||
* Omits logs. | ||
* | ||
* @public | ||
*/ | ||
declare class SilentLogWriter implements LogWriter { | ||
write(): void; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
declare const createLogger: (options?: Partial<LoggerOptions>) => Logger; | ||
declare const _default: Logger; | ||
export { ConsoleLogWriter, type Log, LogLevel, type LogWriter, Logger, type LoggerOptions, SilentLogWriter, createLogger, _default as default, logLevelFromString }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@kosko/log", | ||
"version": "0.0.0-20240324064444", | ||
"version": "0.0.0-20240324074257", | ||
"description": "Logging library for Kosko.", | ||
@@ -50,3 +50,3 @@ "homepage": "https://kosko.dev", | ||
"picocolors": "^1.0.0", | ||
"@kosko/common-utils": "^0.0.0-20240324064444" | ||
"@kosko/common-utils": "^0.0.0-20240324074257" | ||
}, | ||
@@ -53,0 +53,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53548
11
465