standard-log 11.4.1 → 11.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/cjs/logger.js +2 -1
- package/cjs/logger.js.map +1 -1
- package/cjs/types.d.ts +1 -1
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +534 -604
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +170 -149
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/logger.js +2 -1
- package/esm/logger.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +10 -8
- package/ts/logger.ts +1 -1
- package/ts/types.ts +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,11 @@ log.info('info message')
|
|
|
41
41
|
// by default debug() will not be printed
|
|
42
42
|
// because production mode defaults log level to `info`
|
|
43
43
|
log.debug('debug message')
|
|
44
|
+
|
|
45
|
+
// If the message is consume resource to generage,
|
|
46
|
+
// you can use `log.on()` so that it will be called only
|
|
47
|
+
// if the level is met.
|
|
48
|
+
log.on(logLevels.trace, () => prettify(someValue))
|
|
44
49
|
```
|
|
45
50
|
|
|
46
51
|
![Rendering example][rendering-example]
|
package/cjs/logger.js
CHANGED
|
@@ -50,11 +50,12 @@ function createLogger(store, id, options) {
|
|
|
50
50
|
on: {
|
|
51
51
|
writable: false,
|
|
52
52
|
value: function (level, logFn) {
|
|
53
|
+
var _a;
|
|
53
54
|
var logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
|
|
54
55
|
if (shouldLog(store, logLevel, logger.level)) {
|
|
55
56
|
var methodName = store.logLevelStore.getName(logLevel);
|
|
56
57
|
var bindedMethod = logger[methodName].bind(logger);
|
|
57
|
-
var result = logFn(bindedMethod);
|
|
58
|
+
var result = logFn(bindedMethod, (_a = logger.level) !== null && _a !== void 0 ? _a : store.logLevel);
|
|
58
59
|
if (result)
|
|
59
60
|
bindedMethod(result);
|
|
60
61
|
}
|
package/cjs/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA0C;AAK1C,SAAgB,YAAY,CAC1B,KAAe,EAAE,EAAU,EAAE,OAAuB;;IAEpD,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IACnB,IAAM,OAAO,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAA;IAC1C,IAAA,KAAwE,OAAO,OAAO,KAAK,QAAQ;QACvG,CAAC,CAAC,CAAC,UAAA,EAAE,IAAI,OAAA,EAAE,KAAK,OAAO,EAAd,CAAc,EAAE,KAAK,CAAC,SAAS,CAAC;QACzC,CAAC,CAAC,OAAO,YAAY,MAAM;YACzB,CAAC,CAAC,CAAC,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAhB,CAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;YAC3C,CAAC,CAAC,OAAO,OAAO,KAAK,UAAU;gBAC7B,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;gBAC5B,CAAC,CAAC,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,EAAE,CAAC,OAAO,CAAC,CAAC,EANxB,MAAM,QAAA,EAAE,SAAS,QAMO,CAAA;IAE/B,SAAS,KAAK,CAAC,KAAe;QAC5B,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;I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F,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AA1DD,oCA0DC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,OAAO,EAAE,CAAC,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAwB,EAAE,QAAkB,EAAE,MAAuC;IAC7G,SAAS,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAZ,CAAY,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,EAAlB,CAAkB,CAAC,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC1F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import { logLevels } from './logLevels.js'\nimport { LogStore } from './logStore.js'\nimport type { LogEntry, LogFunction, Logger, LoggerOptions, LogMethodNames, LogReporter } from './types.js'\nimport { LogLevel } from './types.js'\n\nexport function createLogger<N extends string = LogMethodNames>(\n store: LogStore, id: string, options?: LoggerOptions\n): Logger<N | LogMethodNames> {\n id = sanitizeId(id)\n const writeTo = options?.writeTo ?? (() => true)\n const [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] = typeof writeTo === 'string'\n ? [id => id === writeTo, store.reporters]\n : writeTo instanceof RegExp\n ? [id => writeTo.test(id), store.reporters]\n : typeof writeTo === 'function'\n ? [writeTo, store.reporters]\n : [() => true, [writeTo]]\n\n function write(entry: LogEntry) {\n writeToReporters(reporters, entry, filter)\n }\n\n const logger = {\n level: options?.level,\n write\n } as any\n\n Object.defineProperties(logger, {\n id: { value: id, writable: false },\n count: {\n writable: false,\n value: ((counter) => (...args: any[]) => {\n if (shouldLog(store, logLevels.debug, logger.level))\n write({\n id,\n level: logLevels.debug,\n args: [++counter, ...args],\n timestamp: new Date()\n })\n })(0)\n },\n on: {\n writable: false,\n value: (level: number | N | LogMethodNames, logFn: LogFunction) => {\n const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n if (shouldLog(store, logLevel, logger.level)) {\n const methodName = store.logLevelStore.getName(logLevel)\n const bindedMethod = logger[methodName].bind(logger)\n const result = logFn(bindedMethod, logger.level ?? store.logLevel)\n if (result) bindedMethod(result)\n }\n }\n }\n })\n store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n Object.defineProperty(logger, name, {\n writable: false,\n value: (...args: any[]) => {\n if (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n }\n })\n })\n return logger\n}\n\nfunction sanitizeId(id: string) {\n return id.replace(/[`~!#$%^&*()=+[\\]{},|<>?]/g, '-')\n}\n\nfunction writeToReporters(reporters: LogReporter[], logEntry: LogEntry, filter: (reporterId: string) => boolean) {\n reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\n/**\n * Determines should you log.\n * @param loggerLevel Log level of the logger.\n * It can be undefined which the global log level will be used.\n */\nfunction shouldLog(store: LogStore, targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"]}
|
package/cjs/types.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare type LogEntry = {
|
|
|
38
38
|
timestamp: Date;
|
|
39
39
|
};
|
|
40
40
|
export declare type LogMethod = (...args: any[]) => void;
|
|
41
|
-
export declare type LogFunction = (
|
|
41
|
+
export declare type LogFunction = (log: LogMethod, logLevel: number) => string | void;
|
|
42
42
|
export declare type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
43
43
|
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
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AAM,CAAA;CAAE,CAAA;AAE3D,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAC7B;AAED,oBAAY,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB,CAAA;AAED,oBAAY,QAAQ,GAAG,MAAM,CAAA;AAE7B,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC7B"}
|
package/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\n\nexport type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {\n customLevels?: Record<CustomLevelNames, number>,\n logLevel?: number,\n reporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n level?: number,\n writeTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n readonly id: string,\n /**\n * Logger local log level.\n */\n level?: number,\n /**\n * Logs with an increment counter.\n * This is useful during debugging to check for steps executed.\n */\n count(...args: any[]): void,\n on(level: number | N, logFunction: LogFunction): void,\n /**\n * Write custom log entries.\n */\n write(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck'\n\nexport type LogEntry = {\n id: string,\n level: number,\n // args instead of messages because it is `any[]` instead of `string[]`\n args: any[],\n timestamp: Date\n}\n\nexport type LogMethod = (...args: any[]) => void\n\nexport type LogFunction = (
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\n\nexport type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {\n customLevels?: Record<CustomLevelNames, number>,\n logLevel?: number,\n reporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n level?: number,\n writeTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n readonly id: string,\n /**\n * Logger local log level.\n */\n level?: number,\n /**\n * Logs with an increment counter.\n * This is useful during debugging to check for steps executed.\n */\n count(...args: any[]): void,\n on(level: number | N, logFunction: LogFunction): void,\n /**\n * Write custom log entries.\n */\n write(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck'\n\nexport type LogEntry = {\n id: string,\n level: number,\n // args instead of messages because it is `any[]` instead of `string[]`\n args: any[],\n timestamp: Date\n}\n\nexport type LogMethod = (...args: any[]) => void\n\nexport type LogFunction = (log: LogMethod, logLevel: number) => string | void\n\nexport type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)\n\nexport interface StandardLogInstance<N extends string = LogMethodNames> {\n logLevel: number,\n toLogLevelName(level: number): string,\n toLogLevel(name: N): number,\n getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>,\n getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n}\n\n/**\n * Formats a log entry.\n * Depends on the reporter, it can expect a different return type.\n * By default the return type is `any[]` which the `console` accepts.\n */\nexport type LogFormatter<T = any[]> = (entry: LogEntry) => T\n\n/**\n * Determines whether the entry should be written.\n */\nexport type LogFilter = (entry: LogEntry) => boolean\n\nexport type LogLevelEntry = { name: string, level: number }\n\nexport interface LogReporter<T = any> {\n readonly id: string,\n /**\n * Specifies the formatter to be used by the reporter.\n * Using this you can customize how the reporter writes the log entry.\n */\n readonly formatter: LogFormatter<T>,\n /**\n * Specifies a filter to determine should the log be written.\n */\n readonly filter?: LogFilter,\n /**\n * Indicate if this is a console reporter.\n * There is only one console reporter can be present in the system.\n */\n readonly isConsoleReporter?: boolean,\n write(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n id?: string,\n /**\n * Specifies the formatter to be used by the reporter.\n * Using this you can customize how the reporter writes the log entry.\n */\n formatter?: LogFormatter<T>,\n /**\n * Specifies a filter to determine should the log be written.\n */\n filter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n debug(...args: any[]): void,\n info(...args: any[]): void,\n warn(...args: any[]): void,\n error(...args: any[]): void,\n}\n"]}
|