@kosko/log
Advanced tools
Comparing version 0.0.0-20240320150839 to 0.0.0-20240324064444
@@ -0,28 +1,6 @@ | ||
import { LogLevel } from "./LogLevel"; | ||
/** | ||
* Logging library. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
/** | ||
* Prints logs to console. | ||
* | ||
* @public | ||
*/ | ||
export declare class ConsoleLogWriter implements LogWriter { | ||
write(log: Log): void; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export declare const createLogger: (options?: Partial<LoggerOptions>) => Logger; | ||
declare const _default: Logger; | ||
export default _default; | ||
/** | ||
* @public | ||
*/ | ||
export declare interface Log { | ||
export interface Log { | ||
loggerLevel: LogLevel; | ||
@@ -35,99 +13,7 @@ level: LogLevel; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export 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; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export declare interface LoggerOptions { | ||
level?: LogLevel; | ||
writer?: LogWriter; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export declare enum LogLevel { | ||
Trace = 1, | ||
Debug = 2, | ||
Info = 3, | ||
Warn = 4, | ||
Error = 5, | ||
Fatal = 6 | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export declare function logLevelFromString(level: string): LogLevel | undefined; | ||
/** | ||
* @public | ||
*/ | ||
export declare interface LogWriter { | ||
export interface LogWriter { | ||
write(log: Log): void; | ||
} | ||
/** | ||
* Omits logs. | ||
* | ||
* @public | ||
*/ | ||
export declare class SilentLogWriter implements LogWriter { | ||
write(): void; | ||
} | ||
export { } |
{ | ||
"name": "@kosko/log", | ||
"version": "0.0.0-20240320150839", | ||
"version": "0.0.0-20240324064444", | ||
"description": "Logging library for Kosko.", | ||
@@ -16,3 +16,3 @@ "homepage": "https://kosko.dev", | ||
"browser": "dist/index.base.mjs", | ||
"types": "dist/types.d.ts", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
@@ -22,13 +22,13 @@ "exports": { | ||
"import": { | ||
"types": "./dist/types.d.mts", | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.node.mjs" | ||
}, | ||
"types": "./dist/types.d.ts", | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.node.cjs" | ||
}, | ||
"import": { | ||
"types": "./dist/types.d.mts", | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.base.mjs" | ||
}, | ||
"types": "./dist/types.d.ts", | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.node.cjs" | ||
@@ -52,7 +52,7 @@ }, | ||
"picocolors": "^1.0.0", | ||
"@kosko/common-utils": "^0.0.0-20240320150839" | ||
"@kosko/common-utils": "^0.0.0-20240324064444" | ||
}, | ||
"devDependencies": { | ||
"@kosko/build-scripts": "^0.0.0", | ||
"@kosko/jest-preset": "^0.0.0" | ||
"@kosko/jest-preset": "^0.0.0", | ||
"@kosko/build-scripts": "^0.0.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
55595
28
492