standard-log 12.0.4 → 12.0.5

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/cjs/types.d.ts CHANGED
@@ -71,9 +71,6 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
71
71
  * Get a logger instance with the specified id.
72
72
  *
73
73
  * ```ts
74
- * import { createStandardLog } from 'standard-log'
75
- *
76
- * const sl = createStandardLog()
77
74
  * const logger = sl.getLogger('my-logger')
78
75
  *
79
76
  * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!
@@ -83,15 +80,12 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
83
80
  /**
84
81
  * Get a non-console logger instance with the specified id.
85
82
  *
86
- * The resulting logger will only write to the reporters that are not console reporters.
83
+ * The resulting logger will only send to the reporters that are not console reporters.
87
84
  *
88
85
  * ```ts
89
- * import { createStandardLog } from 'standard-log'
90
- *
91
- * const sl = createStandardLog({ reporter: [createConsoleReporter(), createRemoteReporter(...)] })
92
86
  * const logger = sl.getNonConsoleLogger('my-logger')
93
87
  *
94
- * logger.info('Hello world!') // will only write to remote reporter
88
+ * logger.info('Hello world!') // will not send to any console reporter
95
89
  * ```
96
90
  */
97
91
  getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,MAAM,kBAAkB,CAAC,gBAAgB,SAAS,MAAM,GAAG,cAAc,IAAI;IAClF;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAA;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAED,MA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AC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;CAC3B"}
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\t/**\n\t * A map of custom log levels.\n\t *\n\t * Each logger created will have a method for each custom level.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ customLevels: { foo: 100 } })\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!\n\t * ```\n\t */\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\n\t| 'emergency'\n\t| 'alert'\n\t| 'critical'\n\t| 'error'\n\t| 'warn'\n\t| 'notice'\n\t| 'info'\n\t| 'debug'\n\t| 'trace'\n\t| 'planck'\n\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: 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\t/**\n\t * The current log level.\n\t */\n\tlogLevel: number\n\t/**\n\t * Convert log level number to log level name.\n\t */\n\ttoLogLevelName(level: number): string\n\t/**\n\t * Convert log level name to log level number.\n\t */\n\ttoLogLevel(name: N): number\n\t/**\n\t * Get a logger instance with the specified id.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog()\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!\n\t * ```\n\t */\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\t/**\n\t * Get a non-console logger instance with the specified id.\n\t *\n\t * The resulting logger will only write to the reporters that are not console reporters.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ reporter: [createConsoleReporter(), createRemoteReporter(...)] })\n\t * const logger = sl.getNonConsoleLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // will only write to remote reporter\n\t * ```\n\t */\n\tgetNonConsoleLogger(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\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicates if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}
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\t/**\n\t * A map of custom log levels.\n\t *\n\t * Each logger created will have a method for each custom level.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ customLevels: { foo: 100 } })\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!\n\t * ```\n\t */\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\n\t| 'emergency'\n\t| 'alert'\n\t| 'critical'\n\t| 'error'\n\t| 'warn'\n\t| 'notice'\n\t| 'info'\n\t| 'debug'\n\t| 'trace'\n\t| 'planck'\n\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: 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\t/**\n\t * The current log level.\n\t */\n\tlogLevel: number\n\t/**\n\t * Convert log level number to log level name.\n\t */\n\ttoLogLevelName(level: number): string\n\t/**\n\t * Convert log level name to log level number.\n\t */\n\ttoLogLevel(name: N): number\n\t/**\n\t * Get a logger instance with the specified id.\n\t *\n\t * ```ts\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!\n\t * ```\n\t */\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\t/**\n\t * Get a non-console logger instance with the specified id.\n\t *\n\t * The resulting logger will only send to the reporters that are not console reporters.\n\t *\n\t * ```ts\n\t * const logger = sl.getNonConsoleLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // will not send to any console reporter\n\t * ```\n\t */\n\tgetNonConsoleLogger(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\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicates if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}
package/esm/types.d.ts CHANGED
@@ -71,9 +71,6 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
71
71
  * Get a logger instance with the specified id.
72
72
  *
73
73
  * ```ts
74
- * import { createStandardLog } from 'standard-log'
75
- *
76
- * const sl = createStandardLog()
77
74
  * const logger = sl.getLogger('my-logger')
78
75
  *
79
76
  * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!
@@ -83,15 +80,12 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
83
80
  /**
84
81
  * Get a non-console logger instance with the specified id.
85
82
  *
86
- * The resulting logger will only write to the reporters that are not console reporters.
83
+ * The resulting logger will only send to the reporters that are not console reporters.
87
84
  *
88
85
  * ```ts
89
- * import { createStandardLog } from 'standard-log'
90
- *
91
- * const sl = createStandardLog({ reporter: [createConsoleReporter(), createRemoteReporter(...)] })
92
86
  * const logger = sl.getNonConsoleLogger('my-logger')
93
87
  *
94
- * logger.info('Hello world!') // will only write to remote reporter
88
+ * logger.info('Hello world!') // will not send to any console reporter
95
89
  * ```
96
90
  */
97
91
  getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethod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C,CAAC,GAAG,GAAG,IAAI;IACzC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE7B,MAAM,WAAW,WAAW;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;CAC3B"}
package/esm/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\t/**\n\t * A map of custom log levels.\n\t *\n\t * Each logger created will have a method for each custom level.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ customLevels: { foo: 100 } })\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!\n\t * ```\n\t */\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\n\t| 'emergency'\n\t| 'alert'\n\t| 'critical'\n\t| 'error'\n\t| 'warn'\n\t| 'notice'\n\t| 'info'\n\t| 'debug'\n\t| 'trace'\n\t| 'planck'\n\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: 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\t/**\n\t * The current log level.\n\t */\n\tlogLevel: number\n\t/**\n\t * Convert log level number to log level name.\n\t */\n\ttoLogLevelName(level: number): string\n\t/**\n\t * Convert log level name to log level number.\n\t */\n\ttoLogLevel(name: N): number\n\t/**\n\t * Get a logger instance with the specified id.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog()\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!\n\t * ```\n\t */\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\t/**\n\t * Get a non-console logger instance with the specified id.\n\t *\n\t * The resulting logger will only write to the reporters that are not console reporters.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ reporter: [createConsoleReporter(), createRemoteReporter(...)] })\n\t * const logger = sl.getNonConsoleLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // will only write to remote reporter\n\t * ```\n\t */\n\tgetNonConsoleLogger(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\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicates if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}
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\t/**\n\t * A map of custom log levels.\n\t *\n\t * Each logger created will have a method for each custom level.\n\t *\n\t * ```ts\n\t * import { createStandardLog } from 'standard-log'\n\t *\n\t * const sl = createStandardLog({ customLevels: { foo: 100 } })\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!\n\t * ```\n\t */\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\n\t| 'emergency'\n\t| 'alert'\n\t| 'critical'\n\t| 'error'\n\t| 'warn'\n\t| 'notice'\n\t| 'info'\n\t| 'debug'\n\t| 'trace'\n\t| 'planck'\n\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: 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\t/**\n\t * The current log level.\n\t */\n\tlogLevel: number\n\t/**\n\t * Convert log level number to log level name.\n\t */\n\ttoLogLevelName(level: number): string\n\t/**\n\t * Convert log level name to log level number.\n\t */\n\ttoLogLevel(name: N): number\n\t/**\n\t * Get a logger instance with the specified id.\n\t *\n\t * ```ts\n\t * const logger = sl.getLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!\n\t * ```\n\t */\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\t/**\n\t * Get a non-console logger instance with the specified id.\n\t *\n\t * The resulting logger will only send to the reporters that are not console reporters.\n\t *\n\t * ```ts\n\t * const logger = sl.getNonConsoleLogger('my-logger')\n\t *\n\t * logger.info('Hello world!') // will not send to any console reporter\n\t * ```\n\t */\n\tgetNonConsoleLogger(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\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicates if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "standard-log",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  "description": "The standard log library",
5
5
  "homepage": "https://github.com/unional/standard-log/tree/main/packages/log",
6
6
  "bugs": {
package/ts/types.ts CHANGED
@@ -89,9 +89,6 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
89
89
  * Get a logger instance with the specified id.
90
90
  *
91
91
  * ```ts
92
- * import { createStandardLog } from 'standard-log'
93
- *
94
- * const sl = createStandardLog()
95
92
  * const logger = sl.getLogger('my-logger')
96
93
  *
97
94
  * logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!
@@ -101,15 +98,12 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
101
98
  /**
102
99
  * Get a non-console logger instance with the specified id.
103
100
  *
104
- * The resulting logger will only write to the reporters that are not console reporters.
101
+ * The resulting logger will only send to the reporters that are not console reporters.
105
102
  *
106
103
  * ```ts
107
- * import { createStandardLog } from 'standard-log'
108
- *
109
- * const sl = createStandardLog({ reporter: [createConsoleReporter(), createRemoteReporter(...)] })
110
104
  * const logger = sl.getNonConsoleLogger('my-logger')
111
105
  *
112
- * logger.info('Hello world!') // will only write to remote reporter
106
+ * logger.info('Hello world!') // will not send to any console reporter
113
107
  * ```
114
108
  */
115
109
  getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>