@idlebox/logger 0.0.23 → 0.0.24
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/lib/common/create.function.d.ts.map +1 -1
- package/lib/common/create.function.js +1 -2
- package/lib/common/create.function.js.map +1 -1
- package/lib/common/types.d.ts +2 -2
- package/lib/environments/browser.d.ts +8 -0
- package/lib/environments/browser.d.ts.map +1 -0
- package/lib/environments/browser.js +21 -0
- package/lib/environments/browser.js.map +1 -0
- package/lib/environments/node.d.ts +12 -0
- package/lib/environments/node.d.ts.map +1 -0
- package/lib/environments/node.js +20 -0
- package/lib/environments/node.js.map +1 -0
- package/lib/environments/share.d.ts +13 -0
- package/lib/environments/share.d.ts.map +1 -0
- package/lib/environments/share.js +7 -0
- package/lib/environments/share.js.map +1 -0
- package/package.json +11 -14
- package/src/common/create.function.ts +2 -4
- package/src/common/types.ts +2 -2
- package/src/environments/browser.ts +26 -0
- package/src/environments/node.ts +26 -0
- package/src/environments/share.ts +31 -0
- package/src/tsconfig.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.function.d.ts","sourceRoot":"","sources":["../../src/common/create.function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.function.d.ts","sourceRoot":"","sources":["../../src/common/create.function.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAY,mBAAmB,EAAkB,MAAM,YAAY,CAAC;AAE7F,UAAU,aAAa;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,cAAsB,EAAE,MAAM,EAAE,OAAc,EAAE,EAAE,aAAa,GAAG,mBAAmB,CAmE5I"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineInspectMethod } from '@idlebox/common';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
2
|
import { call_debug_command, debug_commands, nodeFormat } from '../functions/builtin-commands.js';
|
|
4
3
|
import { Cdim, Crst, CSI, NCdim } from './ansi.js';
|
|
5
4
|
import { LogLevel, logLevelPaddingStr, logTagColor } from './colors.js';
|
|
@@ -29,7 +28,7 @@ export function createDebug({ tag, level, colorEnabled, colorWholeLine = false,
|
|
|
29
28
|
else {
|
|
30
29
|
write_line = write_line_colored_tag(lineOpt);
|
|
31
30
|
}
|
|
32
|
-
assert.equal(typeof writer, 'function', 'writer must be a function');
|
|
31
|
+
// assert.equal(typeof writer, 'function', 'writer must be a function');
|
|
33
32
|
const r = Object.defineProperties((m, ...args) => {
|
|
34
33
|
if (!enabled)
|
|
35
34
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.function.js","sourceRoot":"","sources":["../../src/common/create.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"create.function.js","sourceRoot":"","sources":["../../src/common/create.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,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jB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACP,IAAI,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;QAED,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,MAAmB,EAAE,IAAY,EAAE,IAAY;IAC7D,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACP,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC;AACF,CAAC"}
|
package/lib/common/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
|
2
2
|
/** @ts-ignore */
|
|
3
3
|
export type NodeJSReadableStream = NodeJS.ReadableStream;
|
|
4
4
|
/** @ts-ignore */
|
|
5
|
-
export type
|
|
5
|
+
export type InspectContext = import('node:util').InspectContext;
|
|
6
6
|
export type IMyDebug<T = void> = (message: TemplateStringsArray | string, ...args: readonly any[]) => T;
|
|
7
7
|
export interface IMyDebugWithControl extends IMyDebug {
|
|
8
8
|
enable(): void;
|
|
@@ -39,7 +39,7 @@ export type IDebugCommand = (object: unknown, color: boolean) => string;
|
|
|
39
39
|
export type ILineWriter = (message: string) => any;
|
|
40
40
|
interface UnsupportedMethods {
|
|
41
41
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
42
|
-
dir(item?: any, options?:
|
|
42
|
+
dir(item?: any, options?: InspectContext): void;
|
|
43
43
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
44
44
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
45
45
|
table(tabularData?: any, properties?: string[]): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
2
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
3
|
+
import type { ILoggerOptions } from './share.js';
|
|
4
|
+
export * from './share.js';
|
|
5
|
+
export declare const consoleCompatible: (_input: import("./share.js").IMyLogger) => import("./share.js").IAbstractConsole;
|
|
6
|
+
export declare function createRootLogger(tag: string, defaultLevel?: EnableLogLevel, output?: IInstrestedConsole): void;
|
|
7
|
+
export declare function createLogger(tag: string, options?: ILoggerOptions): import("./share.js").IMyLogger;
|
|
8
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/environments/browser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,cAAc,YAAY,CAAC;AAC3B,eAAO,MAAM,iBAAiB,mFAA8D,CAAC;AAO7F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,cAAoC,EAAE,MAAM,GAAE,kBAAmC,QAE5I;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,kCAKrE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isV8 } from '@idlebox/common';
|
|
2
|
+
import { consoleCompatibleInternal } from '../common/create.compability.js';
|
|
3
|
+
import { createLoggerObject } from '../common/logger.create.js';
|
|
4
|
+
import { createGlobalLogger } from '../common/logger.global.js';
|
|
5
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
6
|
+
export * from './share.js';
|
|
7
|
+
export const consoleCompatible = /*@__PURE__*/ consoleCompatibleInternal.bind(undefined, {});
|
|
8
|
+
const defaultConsole = {
|
|
9
|
+
...console,
|
|
10
|
+
colorEnabled: isV8,
|
|
11
|
+
};
|
|
12
|
+
export function createRootLogger(tag, defaultLevel = EnableLogLevel.auto, output = defaultConsole) {
|
|
13
|
+
createGlobalLogger(output, tag, defaultLevel);
|
|
14
|
+
}
|
|
15
|
+
export function createLogger(tag, options = {}) {
|
|
16
|
+
return createLoggerObject(tag, {
|
|
17
|
+
console: defaultConsole,
|
|
18
|
+
...options,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/environments/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,cAAc,YAAY,CAAC;AAC3B,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAE7F,MAAM,cAAc,GAAG;IACtB,GAAG,OAAO;IACV,YAAY,EAAE,IAAI;CAClB,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,eAA+B,cAAc,CAAC,IAAI,EAAE,SAA6B,cAAc;IAC5I,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,UAA0B,EAAE;IACrE,OAAO,kBAAkB,CAAC,GAAG,EAAE;QAC9B,OAAO,EAAE,cAAc;QACvB,GAAG,OAAO;KACV,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
2
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
3
|
+
import { NodejsOutput } from '../outputs/nodejs.js';
|
|
4
|
+
import type { ILoggerOptions } from './share.js';
|
|
5
|
+
export { createLogFile } from '../printers/file.js';
|
|
6
|
+
export * from './share.js';
|
|
7
|
+
export declare const consoleCompatible: (_input: import("./share.js").IMyLogger) => import("./share.js").IAbstractConsole;
|
|
8
|
+
export declare function createRootLogger(tag: string, defaultLevel?: EnableLogLevel, output?: IInstrestedConsole): void;
|
|
9
|
+
export declare function createLogger(tag: string, options?: ILoggerOptions): import("./share.js").IMyLogger;
|
|
10
|
+
export { applyControllerByEnvironment as getControllerByEnvironment } from '../outputs/node-controllers/index.js';
|
|
11
|
+
export { NodejsOutput };
|
|
12
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/environments/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,cAAc,YAAY,CAAC;AAE3B,eAAO,MAAM,iBAAiB,mFAA8D,CAAC;AAE7F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,cAAoC,EAAE,MAAM,GAAE,kBAAmD,QAE5J;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,kCAKrE;AAED,OAAO,EAAE,4BAA4B,IAAI,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { consoleCompatibleInternal } from '../common/create.compability.js';
|
|
2
|
+
import { createLoggerObject } from '../common/logger.create.js';
|
|
3
|
+
import { createGlobalLogger } from '../common/logger.global.js';
|
|
4
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
5
|
+
import { NodejsOutput } from '../outputs/nodejs.js';
|
|
6
|
+
export { createLogFile } from '../printers/file.js';
|
|
7
|
+
export * from './share.js';
|
|
8
|
+
export const consoleCompatible = /*@__PURE__*/ consoleCompatibleInternal.bind(undefined, {});
|
|
9
|
+
export function createRootLogger(tag, defaultLevel = EnableLogLevel.auto, output = NodejsOutput.defaultInstance()) {
|
|
10
|
+
createGlobalLogger(output, tag, defaultLevel);
|
|
11
|
+
}
|
|
12
|
+
export function createLogger(tag, options = {}) {
|
|
13
|
+
return createLoggerObject(tag, {
|
|
14
|
+
console: NodejsOutput.defaultInstance(),
|
|
15
|
+
...options,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { applyControllerByEnvironment as getControllerByEnvironment } from '../outputs/node-controllers/index.js';
|
|
19
|
+
export { NodejsOutput };
|
|
20
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/environments/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,cAAc,YAAY,CAAC;AAE3B,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAE7F,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,eAA+B,cAAc,CAAC,IAAI,EAAE,SAA6B,YAAY,CAAC,eAAe,EAAE;IAC5J,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,UAA0B,EAAE;IACrE,OAAO,kBAAkB,CAAC,GAAG,EAAE;QAC9B,OAAO,EAAE,YAAY,CAAC,eAAe,EAAE;QACvC,GAAG,OAAO;KACV,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,4BAA4B,IAAI,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ILoggerOptionsReq } from '../common/logger.create.js';
|
|
2
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
3
|
+
export { logTagColor } from '../common/colors.js';
|
|
4
|
+
export { createDebug } from '../common/create.function.js';
|
|
5
|
+
export { debug_enabled, is_string_truthy, match_disabled, match_enabled, set_default_log_level, set_error_action, } from '../common/helpers.js';
|
|
6
|
+
export { globalLogger as logger } from '../common/logger.global.js';
|
|
7
|
+
export type { IAbstractConsole, IConsole, IDebugCommand, ILineWriter, IMyDebug, IMyDebugWithControl, IMyLogger, IMyLoggerMethods, } from '../common/types.js';
|
|
8
|
+
export { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
9
|
+
export { enableLoggerRegistry, getAllLoggerNames, getAllLoggers } from '../common/registry.js';
|
|
10
|
+
export interface ILoggerOptions extends Omit<ILoggerOptionsReq, 'console'> {
|
|
11
|
+
readonly console?: IInstrestedConsole;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=share.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../src/environments/share.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EACX,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,gBAAgB,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE/F,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;CACtC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { logTagColor } from '../common/colors.js';
|
|
2
|
+
export { createDebug } from '../common/create.function.js';
|
|
3
|
+
export { debug_enabled, is_string_truthy, match_disabled, match_enabled, set_default_log_level, set_error_action, } from '../common/helpers.js';
|
|
4
|
+
export { globalLogger as logger } from '../common/logger.global.js';
|
|
5
|
+
export { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
6
|
+
export { enableLoggerRegistry, getAllLoggerNames, getAllLoggers } from '../common/registry.js';
|
|
7
|
+
//# sourceMappingURL=share.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../src/environments/share.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAWpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlebox/logger",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.24",
|
|
5
5
|
"description": "A simple logger module for my self use (nodejs).",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"source": "./src/
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"./node": {
|
|
13
|
-
"default": "./lib/_environments/node.js"
|
|
14
|
-
},
|
|
15
|
-
"./browser": {
|
|
16
|
-
"default": "./lib/_environments/browser.js"
|
|
8
|
+
"source": "./src/environments/node.ts",
|
|
9
|
+
"browser": "./lib/environments/browser.js",
|
|
10
|
+
"node": "./lib/environments/node.js",
|
|
11
|
+
"default": "./lib/environments/browser.js"
|
|
17
12
|
},
|
|
13
|
+
"./node": "./lib/environments/node.js",
|
|
14
|
+
"./browser": "./lib/environments/browser.js",
|
|
18
15
|
"./package.json": "./package.json"
|
|
19
16
|
},
|
|
20
17
|
"sideEffects": false,
|
|
21
18
|
"dependencies": {
|
|
22
19
|
"debug": "^4.4.3",
|
|
23
|
-
"@idlebox/
|
|
24
|
-
"@idlebox/
|
|
20
|
+
"@idlebox/common": "^1.5.22",
|
|
21
|
+
"@idlebox/terminal-control": "^0.0.4"
|
|
25
22
|
},
|
|
26
23
|
"devDependencies": {
|
|
27
24
|
"@types/debug": "^4.1.13",
|
|
28
25
|
"@types/node": "^25.5.0",
|
|
29
26
|
"mocha": "^11.7.5",
|
|
30
|
-
"@mpis/run": "^0.0.
|
|
27
|
+
"@mpis/run": "^0.0.26",
|
|
31
28
|
"@build-script/baseline-rig": "latest"
|
|
32
29
|
},
|
|
33
30
|
"license": "MIT",
|
|
@@ -37,7 +34,7 @@
|
|
|
37
34
|
"url": "git+https://github.com/GongT/baobao.git",
|
|
38
35
|
"directory": "@idlebox/logger"
|
|
39
36
|
},
|
|
40
|
-
"main": "./lib/
|
|
37
|
+
"main": "./lib/environments/browser.js",
|
|
41
38
|
"scripts": {
|
|
42
39
|
"build": "mpis-run build",
|
|
43
40
|
"watch": "mpis-run watch",
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { defineInspectMethod } from '@idlebox/common';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import type { InspectContext } from 'node:util';
|
|
4
2
|
import { call_debug_command, debug_commands, nodeFormat } from '../functions/builtin-commands.js';
|
|
5
3
|
import { Cdim, Crst, CSI, NCdim } from './ansi.js';
|
|
6
4
|
import { LogLevel, logLevelPaddingStr, logTagColor } from './colors.js';
|
|
7
5
|
import { current_error_action, escapeRegExp } from './helpers.js';
|
|
8
|
-
import type { ILineWriter, IMyDebug, IMyDebugWithControl } from './types.js';
|
|
6
|
+
import type { ILineWriter, IMyDebug, IMyDebugWithControl, InspectContext } from './types.js';
|
|
9
7
|
|
|
10
8
|
interface IDebugOptions {
|
|
11
9
|
tag: string;
|
|
@@ -41,7 +39,7 @@ export function createDebug({ tag, level, colorEnabled, colorWholeLine = false,
|
|
|
41
39
|
write_line = write_line_colored_tag(lineOpt);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
assert.equal(typeof writer, 'function', 'writer must be a function');
|
|
42
|
+
// assert.equal(typeof writer, 'function', 'writer must be a function');
|
|
45
43
|
|
|
46
44
|
const r = Object.defineProperties(
|
|
47
45
|
(m: any, ...args: unknown[]) => {
|
package/src/common/types.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
|
6
6
|
export type NodeJSReadableStream = NodeJS.ReadableStream;
|
|
7
7
|
|
|
8
8
|
/** @ts-ignore */
|
|
9
|
-
export type
|
|
9
|
+
export type InspectContext = import('node:util').InspectContext;
|
|
10
10
|
|
|
11
11
|
export type IMyDebug<T = void> = (message: TemplateStringsArray | string, ...args: readonly any[]) => T;
|
|
12
12
|
|
|
@@ -64,7 +64,7 @@ export type ILineWriter = (message: string) => any;
|
|
|
64
64
|
|
|
65
65
|
interface UnsupportedMethods {
|
|
66
66
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
67
|
-
dir(item?: any, options?:
|
|
67
|
+
dir(item?: any, options?: InspectContext): void;
|
|
68
68
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
69
69
|
/** @deprecated 模拟console对象不支持此方法 */
|
|
70
70
|
table(tabularData?: any, properties?: string[]): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isV8 } from '@idlebox/common';
|
|
2
|
+
import { consoleCompatibleInternal } from '../common/create.compability.js';
|
|
3
|
+
import { createLoggerObject } from '../common/logger.create.js';
|
|
4
|
+
import { createGlobalLogger } from '../common/logger.global.js';
|
|
5
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
6
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
7
|
+
import type { ILoggerOptions } from './share.js';
|
|
8
|
+
|
|
9
|
+
export * from './share.js';
|
|
10
|
+
export const consoleCompatible = /*@__PURE__*/ consoleCompatibleInternal.bind(undefined, {});
|
|
11
|
+
|
|
12
|
+
const defaultConsole = {
|
|
13
|
+
...console,
|
|
14
|
+
colorEnabled: isV8,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function createRootLogger(tag: string, defaultLevel: EnableLogLevel = EnableLogLevel.auto, output: IInstrestedConsole = defaultConsole) {
|
|
18
|
+
createGlobalLogger(output, tag, defaultLevel);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createLogger(tag: string, options: ILoggerOptions = {}) {
|
|
22
|
+
return createLoggerObject(tag, {
|
|
23
|
+
console: defaultConsole,
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { consoleCompatibleInternal } from '../common/create.compability.js';
|
|
2
|
+
import { createLoggerObject } from '../common/logger.create.js';
|
|
3
|
+
import { createGlobalLogger } from '../common/logger.global.js';
|
|
4
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
5
|
+
import { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
6
|
+
import { NodejsOutput } from '../outputs/nodejs.js';
|
|
7
|
+
import type { ILoggerOptions } from './share.js';
|
|
8
|
+
|
|
9
|
+
export { createLogFile } from '../printers/file.js';
|
|
10
|
+
export * from './share.js';
|
|
11
|
+
|
|
12
|
+
export const consoleCompatible = /*@__PURE__*/ consoleCompatibleInternal.bind(undefined, {});
|
|
13
|
+
|
|
14
|
+
export function createRootLogger(tag: string, defaultLevel: EnableLogLevel = EnableLogLevel.auto, output: IInstrestedConsole = NodejsOutput.defaultInstance()) {
|
|
15
|
+
createGlobalLogger(output, tag, defaultLevel);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function createLogger(tag: string, options: ILoggerOptions = {}) {
|
|
19
|
+
return createLoggerObject(tag, {
|
|
20
|
+
console: NodejsOutput.defaultInstance(),
|
|
21
|
+
...options,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { applyControllerByEnvironment as getControllerByEnvironment } from '../outputs/node-controllers/index.js';
|
|
26
|
+
export { NodejsOutput };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ILoggerOptionsReq } from '../common/logger.create.js';
|
|
2
|
+
import type { IInstrestedConsole } from '../common/types.js';
|
|
3
|
+
|
|
4
|
+
export { logTagColor } from '../common/colors.js';
|
|
5
|
+
export { createDebug } from '../common/create.function.js';
|
|
6
|
+
export {
|
|
7
|
+
debug_enabled,
|
|
8
|
+
is_string_truthy,
|
|
9
|
+
match_disabled,
|
|
10
|
+
match_enabled,
|
|
11
|
+
set_default_log_level,
|
|
12
|
+
set_error_action,
|
|
13
|
+
} from '../common/helpers.js';
|
|
14
|
+
export { globalLogger as logger } from '../common/logger.global.js';
|
|
15
|
+
export type {
|
|
16
|
+
IAbstractConsole,
|
|
17
|
+
IConsole,
|
|
18
|
+
IDebugCommand,
|
|
19
|
+
ILineWriter,
|
|
20
|
+
IMyDebug,
|
|
21
|
+
IMyDebugWithControl,
|
|
22
|
+
IMyLogger,
|
|
23
|
+
IMyLoggerMethods,
|
|
24
|
+
} from '../common/types.js';
|
|
25
|
+
export { EnableLogLevel } from '../loglevels/loglevel.js';
|
|
26
|
+
|
|
27
|
+
export { enableLoggerRegistry, getAllLoggerNames, getAllLoggers } from '../common/registry.js';
|
|
28
|
+
|
|
29
|
+
export interface ILoggerOptions extends Omit<ILoggerOptionsReq, 'console'> {
|
|
30
|
+
readonly console?: IInstrestedConsole;
|
|
31
|
+
}
|