@nexeraid/logger
Advanced tools
Comparing version 2.3.0-dev to 2.3.13-dev
@@ -1,9 +0,40 @@ | ||
import type { LevelWithSilentOrString } from "pino"; | ||
import pino from "pino"; | ||
/** | ||
* don't extend pino types to prevent errors like: | ||
* XXX cannot be named without a reference to '../../../public/logger/node_modules/pino/pino'. | ||
* This is likely not portable. A type annotation is necessary.ts(2742) | ||
* | ||
* To avoid the pino type dependency we copy the minimal types needed here. | ||
*/ | ||
export type LoggerLevel = "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent"; | ||
export declare const loggerLevels: readonly ["fatal", "error", "warn", "info", "debug", "trace", "silent"]; | ||
type LogFn = { | ||
<T extends object>(obj: T, msg?: string, ...args: any[]): void; | ||
(obj: unknown, msg?: string, ...args: any[]): void; | ||
(msg: string, ...args: any[]): void; | ||
}; | ||
export type Logger = { | ||
fatal: LogFn; | ||
error: LogFn; | ||
warn: LogFn; | ||
info: LogFn; | ||
debug: LogFn; | ||
trace: LogFn; | ||
silent: LogFn; | ||
child: (bindings: Record<string, any>, options?: { | ||
level?: LoggerLevel; | ||
redact?: string[]; | ||
msgPrefix?: string; | ||
}) => Logger; | ||
setBindings: (bindings: Record<string, any>) => void; | ||
}; | ||
export declare const createLogger: (config: { | ||
name: string; | ||
level?: LevelWithSilentOrString; | ||
}) => import("pino").Logger<never, boolean>; | ||
export type Logger = ReturnType<typeof createLogger>; | ||
export type pino = typeof pino; | ||
level?: LoggerLevel; | ||
}) => Logger; | ||
export declare const createLogTimer: (logger: Logger) => { | ||
time: (name: string) => void; | ||
timeEnd: (name: string) => void; | ||
}; | ||
export type LogTimer = ReturnType<typeof createLogTimer>; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,2 +12,11 @@ 'use strict'; | ||
/** | ||
* don't extend pino types to prevent errors like: | ||
* XXX cannot be named without a reference to '../../../public/logger/node_modules/pino/pino'. | ||
* This is likely not portable. A type annotation is necessary.ts(2742) | ||
* | ||
* To avoid the pino type dependency we copy the minimal types needed here. | ||
*/ | ||
var loggerLevels = ["fatal", "error", "warn", "info", "debug", "trace", "silent"]; | ||
var createLogger = function createLogger(config) { | ||
@@ -28,2 +37,24 @@ var _config$level; | ||
// https://github.com/pinojs/pino/issues/1011#issuecomment-819094108 | ||
var createLogTimer = function createLogTimer(logger) { | ||
var timers = {}; | ||
return { | ||
time: function time(name) { | ||
timers[name] = Date.now(); | ||
}, | ||
timeEnd: function timeEnd(name) { | ||
var timer = timers[name]; | ||
if (timer) { | ||
logger.debug({ | ||
msg: "Timer ".concat(name), | ||
time: Date.now() - timer | ||
}); | ||
delete timers[name]; | ||
} | ||
} | ||
}; | ||
}; | ||
exports.createLogTimer = createLogTimer; | ||
exports.createLogger = createLogger; | ||
exports.loggerLevels = loggerLevels; |
@@ -12,2 +12,11 @@ 'use strict'; | ||
/** | ||
* don't extend pino types to prevent errors like: | ||
* XXX cannot be named without a reference to '../../../public/logger/node_modules/pino/pino'. | ||
* This is likely not portable. A type annotation is necessary.ts(2742) | ||
* | ||
* To avoid the pino type dependency we copy the minimal types needed here. | ||
*/ | ||
var loggerLevels = ["fatal", "error", "warn", "info", "debug", "trace", "silent"]; | ||
var createLogger = function createLogger(config) { | ||
@@ -28,2 +37,24 @@ var _config$level; | ||
// https://github.com/pinojs/pino/issues/1011#issuecomment-819094108 | ||
var createLogTimer = function createLogTimer(logger) { | ||
var timers = {}; | ||
return { | ||
time: function time(name) { | ||
timers[name] = Date.now(); | ||
}, | ||
timeEnd: function timeEnd(name) { | ||
var timer = timers[name]; | ||
if (timer) { | ||
logger.debug({ | ||
msg: "Timer ".concat(name), | ||
time: Date.now() - timer | ||
}); | ||
delete timers[name]; | ||
} | ||
} | ||
}; | ||
}; | ||
exports.createLogTimer = createLogTimer; | ||
exports.createLogger = createLogger; | ||
exports.loggerLevels = loggerLevels; |
import pino from 'pino'; | ||
import { err } from 'pino-std-serializers'; | ||
/** | ||
* don't extend pino types to prevent errors like: | ||
* XXX cannot be named without a reference to '../../../public/logger/node_modules/pino/pino'. | ||
* This is likely not portable. A type annotation is necessary.ts(2742) | ||
* | ||
* To avoid the pino type dependency we copy the minimal types needed here. | ||
*/ | ||
var loggerLevels = ["fatal", "error", "warn", "info", "debug", "trace", "silent"]; | ||
var createLogger = function createLogger(config) { | ||
@@ -19,2 +28,22 @@ var _config$level; | ||
export { createLogger }; | ||
// https://github.com/pinojs/pino/issues/1011#issuecomment-819094108 | ||
var createLogTimer = function createLogTimer(logger) { | ||
var timers = {}; | ||
return { | ||
time: function time(name) { | ||
timers[name] = Date.now(); | ||
}, | ||
timeEnd: function timeEnd(name) { | ||
var timer = timers[name]; | ||
if (timer) { | ||
logger.debug({ | ||
msg: "Timer ".concat(name), | ||
time: Date.now() - timer | ||
}); | ||
delete timers[name]; | ||
} | ||
} | ||
}; | ||
}; | ||
export { createLogTimer, createLogger, loggerLevels }; |
{ | ||
"name": "@nexeraid/logger", | ||
"version": "2.3.0", | ||
"version": "2.3.13", | ||
"description": "Unblokt Technology Logger for node and browser", | ||
@@ -35,3 +35,4 @@ "keywords": [], | ||
"extends": [ | ||
"@unblokttechnology/eslint-config/base" | ||
"@unblokttechnology/eslint-config/base", | ||
"@unblokttechnology/eslint-config/public" | ||
], | ||
@@ -38,0 +39,0 @@ "root": true |
{ | ||
"name": "@nexeraid/logger", | ||
"version": "2.3.0-dev", | ||
"version": "2.3.13-dev", | ||
"description": "Unblokt Technology Logger for node and browser", | ||
@@ -22,3 +22,4 @@ "keywords": [], | ||
"extends": [ | ||
"@unblokttechnology/eslint-config/base" | ||
"@unblokttechnology/eslint-config/base", | ||
"@unblokttechnology/eslint-config/public" | ||
], | ||
@@ -25,0 +26,0 @@ "root": true |
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
11111
191