@adviser/cement 0.0.0-jsr-t1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +39 -0
- package/base-sys-abstraction-BkEiLHl0.d.ts +193 -0
- package/base-sys-abstraction-Qj7pkY1N.d.cts +193 -0
- package/chunk-7KFVMTOS.js +311 -0
- package/chunk-7KFVMTOS.js.map +1 -0
- package/chunk-GES3MUGV.js +92 -0
- package/chunk-GES3MUGV.js.map +1 -0
- package/chunk-Q65HLCNL.js +601 -0
- package/chunk-Q65HLCNL.js.map +1 -0
- package/chunk-WMMUXBDX.js +87 -0
- package/chunk-WMMUXBDX.js.map +1 -0
- package/index-Q3phXzYr.d.cts +75 -0
- package/index-tIGZMHTc.d.ts +75 -0
- package/index.cjs +2593 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +532 -0
- package/index.d.ts +532 -0
- package/index.js +1533 -0
- package/index.js.map +1 -0
- package/node/index.cjs +924 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +65 -0
- package/node/index.d.ts +65 -0
- package/node/index.js +398 -0
- package/node/index.js.map +1 -0
- package/package.json +81 -0
- package/src/base-sys-abstraction.test.ts +95 -0
- package/src/base-sys-abstraction.ts +242 -0
- package/src/bin2text.test.ts +59 -0
- package/src/bin2text.ts +47 -0
- package/src/crypto.test.ts +15 -0
- package/src/crypto.ts +125 -0
- package/src/file-service.ts +24 -0
- package/src/future.test.ts +32 -0
- package/src/future.ts +27 -0
- package/src/index.ts +22 -0
- package/src/jsr.json +20 -0
- package/src/log-level-impl.ts +87 -0
- package/src/log-writer-impl.ts +58 -0
- package/src/logger-impl.ts +498 -0
- package/src/logger.test.ts +1132 -0
- package/src/logger.ts +208 -0
- package/src/node/deno-file-service.ts +92 -0
- package/src/node/deno-sys-abstraction.ts +133 -0
- package/src/node/index.ts +4 -0
- package/src/node/mock-file-service.ts +45 -0
- package/src/node/node-file-service.ts +91 -0
- package/src/node/node-sys-abstraction.ts +121 -0
- package/src/option.ts +60 -0
- package/src/resolve-once.test.ts +321 -0
- package/src/resolve-once.ts +179 -0
- package/src/result.test.ts +102 -0
- package/src/result.ts +165 -0
- package/src/runtime.ts +36 -0
- package/src/sys-abstraction.ts +53 -0
- package/src/sys-env.test.ts +53 -0
- package/src/sys-env.ts +216 -0
- package/src/test/log-write-stream.ts +95 -0
- package/src/test/mock-logger.ts +40 -0
- package/src/time.ts +20 -0
- package/src/tracer.test.ts +314 -0
- package/src/tracer.ts +222 -0
- package/src/txt-en-decoder.ts +21 -0
- package/src/uri.test.ts +155 -0
- package/src/uri.ts +421 -0
- package/src/utils/console-write-stream.ts +72 -0
- package/src/utils/fanout-write-stream.ts +32 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/rebuffer.ts +75 -0
- package/src/utils/stream-map.ts +67 -0
- package/src/utils/stream2string.ts +47 -0
- package/src/utils/string2stream.ts +14 -0
- package/src/version.ts +3 -0
- package/src/web/index.ts +1 -0
- package/src/web/web-sys-abstraction.ts +80 -0
- package/ts/LICENSE +201 -0
- package/ts/README.md +39 -0
- package/ts/base-sys-abstraction.d.ts +84 -0
- package/ts/base-sys-abstraction.d.ts.map +1 -0
- package/ts/base-sys-abstraction.js +178 -0
- package/ts/base-sys-abstraction.js.map +1 -0
- package/ts/base-sys-abstraction.test.d.ts +2 -0
- package/ts/base-sys-abstraction.test.d.ts.map +1 -0
- package/ts/base-sys-abstraction.test.js +82 -0
- package/ts/base-sys-abstraction.test.js.map +1 -0
- package/ts/bin2text.d.ts +3 -0
- package/ts/bin2text.d.ts.map +1 -0
- package/ts/bin2text.js +43 -0
- package/ts/bin2text.js.map +1 -0
- package/ts/bin2text.test.d.ts +2 -0
- package/ts/bin2text.test.d.ts.map +1 -0
- package/ts/bin2text.test.js +51 -0
- package/ts/bin2text.test.js.map +1 -0
- package/ts/crypto.d.ts +76 -0
- package/ts/crypto.d.ts.map +1 -0
- package/ts/crypto.js +22 -0
- package/ts/crypto.js.map +1 -0
- package/ts/crypto.test.d.ts +2 -0
- package/ts/crypto.test.d.ts.map +1 -0
- package/ts/crypto.test.js +14 -0
- package/ts/crypto.test.js.map +1 -0
- package/ts/file-service.d.ts +17 -0
- package/ts/file-service.d.ts.map +1 -0
- package/ts/file-service.js +2 -0
- package/ts/file-service.js.map +1 -0
- package/ts/future.d.ts +8 -0
- package/ts/future.d.ts.map +1 -0
- package/ts/future.js +38 -0
- package/ts/future.js.map +1 -0
- package/ts/future.test.d.ts +2 -0
- package/ts/future.test.d.ts.map +1 -0
- package/ts/future.test.js +28 -0
- package/ts/future.test.js.map +1 -0
- package/ts/index.d.ts +23 -0
- package/ts/index.d.ts.map +1 -0
- package/ts/index.js +23 -0
- package/ts/index.js.map +1 -0
- package/ts/log-level-impl.d.ts +14 -0
- package/ts/log-level-impl.d.ts.map +1 -0
- package/ts/log-level-impl.js +72 -0
- package/ts/log-level-impl.js.map +1 -0
- package/ts/log-writer-impl.d.ts +10 -0
- package/ts/log-writer-impl.d.ts.map +1 -0
- package/ts/log-writer-impl.js +45 -0
- package/ts/log-writer-impl.js.map +1 -0
- package/ts/logger-impl.d.ts +71 -0
- package/ts/logger-impl.d.ts.map +1 -0
- package/ts/logger-impl.js +412 -0
- package/ts/logger-impl.js.map +1 -0
- package/ts/logger.d.ts +84 -0
- package/ts/logger.d.ts.map +1 -0
- package/ts/logger.js +114 -0
- package/ts/logger.js.map +1 -0
- package/ts/logger.test.d.ts +2 -0
- package/ts/logger.test.d.ts.map +1 -0
- package/ts/logger.test.js +1023 -0
- package/ts/logger.test.js.map +1 -0
- package/ts/node/deno-file-service.d.ts +17 -0
- package/ts/node/deno-file-service.d.ts.map +1 -0
- package/ts/node/deno-file-service.js +65 -0
- package/ts/node/deno-file-service.js.map +1 -0
- package/ts/node/deno-sys-abstraction.d.ts +22 -0
- package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/node/deno-sys-abstraction.js +101 -0
- package/ts/node/deno-sys-abstraction.js.map +1 -0
- package/ts/node/index.d.ts +5 -0
- package/ts/node/index.d.ts.map +1 -0
- package/ts/node/index.js +5 -0
- package/ts/node/index.js.map +1 -0
- package/ts/node/mock-file-service.d.ts +11 -0
- package/ts/node/mock-file-service.d.ts.map +1 -0
- package/ts/node/mock-file-service.js +34 -0
- package/ts/node/mock-file-service.js.map +1 -0
- package/ts/node/mock-file-service.test.d.ts +2 -0
- package/ts/node/mock-file-service.test.d.ts.map +1 -0
- package/ts/node/mock-file-service.test.js +31 -0
- package/ts/node/mock-file-service.test.js.map +1 -0
- package/ts/node/node-file-service.d.ts +16 -0
- package/ts/node/node-file-service.d.ts.map +1 -0
- package/ts/node/node-file-service.js +71 -0
- package/ts/node/node-file-service.js.map +1 -0
- package/ts/node/node-sys-abstraction.d.ts +22 -0
- package/ts/node/node-sys-abstraction.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.js +99 -0
- package/ts/node/node-sys-abstraction.js.map +1 -0
- package/ts/node/node-sys-abstraction.test.d.ts +2 -0
- package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.test.js +87 -0
- package/ts/node/node-sys-abstraction.test.js.map +1 -0
- package/ts/option.d.ts +25 -0
- package/ts/option.d.ts.map +1 -0
- package/ts/option.js +47 -0
- package/ts/option.js.map +1 -0
- package/ts/resolve-once.d.ts +46 -0
- package/ts/resolve-once.d.ts.map +1 -0
- package/ts/resolve-once.js +152 -0
- package/ts/resolve-once.js.map +1 -0
- package/ts/resolve-once.test.d.ts +2 -0
- package/ts/resolve-once.test.d.ts.map +1 -0
- package/ts/resolve-once.test.js +283 -0
- package/ts/resolve-once.test.js.map +1 -0
- package/ts/result.d.ts +34 -0
- package/ts/result.d.ts.map +1 -0
- package/ts/result.js +85 -0
- package/ts/result.js.map +1 -0
- package/ts/result.test.d.ts +2 -0
- package/ts/result.test.d.ts.map +1 -0
- package/ts/result.test.js +79 -0
- package/ts/result.test.js.map +1 -0
- package/ts/runtime.d.ts +8 -0
- package/ts/runtime.d.ts.map +1 -0
- package/ts/runtime.js +26 -0
- package/ts/runtime.js.map +1 -0
- package/ts/sys-abstraction.d.ts +36 -0
- package/ts/sys-abstraction.d.ts.map +1 -0
- package/ts/sys-abstraction.js +31 -0
- package/ts/sys-abstraction.js.map +1 -0
- package/ts/sys-env.d.ts +48 -0
- package/ts/sys-env.d.ts.map +1 -0
- package/ts/sys-env.js +176 -0
- package/ts/sys-env.js.map +1 -0
- package/ts/sys-env.test.d.ts +2 -0
- package/ts/sys-env.test.d.ts.map +1 -0
- package/ts/sys-env.test.js +51 -0
- package/ts/sys-env.test.js.map +1 -0
- package/ts/test/log-write-stream.d.ts +27 -0
- package/ts/test/log-write-stream.d.ts.map +1 -0
- package/ts/test/log-write-stream.js +74 -0
- package/ts/test/log-write-stream.js.map +1 -0
- package/ts/test/mock-logger.d.ts +14 -0
- package/ts/test/mock-logger.d.ts.map +1 -0
- package/ts/test/mock-logger.js +29 -0
- package/ts/test/mock-logger.js.map +1 -0
- package/ts/test/mock-logger.test.d.ts +2 -0
- package/ts/test/mock-logger.test.d.ts.map +1 -0
- package/ts/test/mock-logger.test.js +63 -0
- package/ts/test/mock-logger.test.js.map +1 -0
- package/ts/test/test-exit-handler.d.ts +2 -0
- package/ts/test/test-exit-handler.d.ts.map +1 -0
- package/ts/test/test-exit-handler.js +57 -0
- package/ts/test/test-exit-handler.js.map +1 -0
- package/ts/time.d.ts +13 -0
- package/ts/time.d.ts.map +1 -0
- package/ts/time.js +14 -0
- package/ts/time.js.map +1 -0
- package/ts/tracer.d.ts +59 -0
- package/ts/tracer.d.ts.map +1 -0
- package/ts/tracer.js +148 -0
- package/ts/tracer.js.map +1 -0
- package/ts/tracer.test.d.ts +2 -0
- package/ts/tracer.test.d.ts.map +1 -0
- package/ts/tracer.test.js +311 -0
- package/ts/tracer.test.js.map +1 -0
- package/ts/txt-en-decoder.d.ts +10 -0
- package/ts/txt-en-decoder.d.ts.map +1 -0
- package/ts/txt-en-decoder.js +15 -0
- package/ts/txt-en-decoder.js.map +1 -0
- package/ts/uri.d.ts +67 -0
- package/ts/uri.d.ts.map +1 -0
- package/ts/uri.js +283 -0
- package/ts/uri.js.map +1 -0
- package/ts/uri.test.d.ts +2 -0
- package/ts/uri.test.d.ts.map +1 -0
- package/ts/uri.test.js +119 -0
- package/ts/uri.test.js.map +1 -0
- package/ts/utils/console-write-stream.d.ts +21 -0
- package/ts/utils/console-write-stream.d.ts.map +1 -0
- package/ts/utils/console-write-stream.js +62 -0
- package/ts/utils/console-write-stream.js.map +1 -0
- package/ts/utils/fanout-write-stream.d.ts +12 -0
- package/ts/utils/fanout-write-stream.d.ts.map +1 -0
- package/ts/utils/fanout-write-stream.js +24 -0
- package/ts/utils/fanout-write-stream.js.map +1 -0
- package/ts/utils/index.d.ts +7 -0
- package/ts/utils/index.d.ts.map +1 -0
- package/ts/utils/index.js +7 -0
- package/ts/utils/index.js.map +1 -0
- package/ts/utils/rebuffer.d.ts +3 -0
- package/ts/utils/rebuffer.d.ts.map +1 -0
- package/ts/utils/rebuffer.js +60 -0
- package/ts/utils/rebuffer.js.map +1 -0
- package/ts/utils/rebuffer.test.d.ts +2 -0
- package/ts/utils/rebuffer.test.d.ts.map +1 -0
- package/ts/utils/rebuffer.test.js +77 -0
- package/ts/utils/rebuffer.test.js.map +1 -0
- package/ts/utils/stream-map.d.ts +9 -0
- package/ts/utils/stream-map.d.ts.map +1 -0
- package/ts/utils/stream-map.js +62 -0
- package/ts/utils/stream-map.js.map +1 -0
- package/ts/utils/stream-map.test.d.ts +2 -0
- package/ts/utils/stream-map.test.d.ts.map +1 -0
- package/ts/utils/stream-map.test.js +87 -0
- package/ts/utils/stream-map.test.js.map +1 -0
- package/ts/utils/stream-test-helper.d.ts +17 -0
- package/ts/utils/stream-test-helper.d.ts.map +1 -0
- package/ts/utils/stream-test-helper.js +37 -0
- package/ts/utils/stream-test-helper.js.map +1 -0
- package/ts/utils/stream2string.d.ts +3 -0
- package/ts/utils/stream2string.d.ts.map +1 -0
- package/ts/utils/stream2string.js +48 -0
- package/ts/utils/stream2string.js.map +1 -0
- package/ts/utils/stream2string.test.d.ts +2 -0
- package/ts/utils/stream2string.test.d.ts.map +1 -0
- package/ts/utils/stream2string.test.js +29 -0
- package/ts/utils/stream2string.test.js.map +1 -0
- package/ts/utils/string2stream.d.ts +4 -0
- package/ts/utils/string2stream.d.ts.map +1 -0
- package/ts/utils/string2stream.js +13 -0
- package/ts/utils/string2stream.js.map +1 -0
- package/ts/utils/string2stream.test.d.ts +2 -0
- package/ts/utils/string2stream.test.d.ts.map +1 -0
- package/ts/utils/string2stream.test.js +6 -0
- package/ts/utils/string2stream.test.js.map +1 -0
- package/ts/version.d.ts +2 -0
- package/ts/version.d.ts.map +1 -0
- package/ts/version.js +4 -0
- package/ts/version.js.map +1 -0
- package/ts/web/index.d.ts +2 -0
- package/ts/web/index.d.ts.map +1 -0
- package/ts/web/index.js +2 -0
- package/ts/web/index.js.map +1 -0
- package/ts/web/web-sys-abstraction.d.ts +4 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -0
- package/ts/web/web-sys-abstraction.js +64 -0
- package/ts/web/web-sys-abstraction.js.map +1 -0
- package/txt-en-decoder-CZYJUju2.d.cts +11 -0
- package/txt-en-decoder-CZYJUju2.d.ts +11 -0
- package/utils/index.cjs +341 -0
- package/utils/index.cjs.map +1 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +32 -0
- package/utils/index.js.map +1 -0
- package/web/index.cjs +593 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +6 -0
- package/web/index.d.ts +6 -0
- package/web/index.js +9 -0
- package/web/index.js.map +1 -0
package/ts/logger.d.ts
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
import { Result } from "./result.js";
|
2
|
+
import { TxtEnDecoder } from "./txt-en-decoder.js";
|
3
|
+
import { CoerceURI } from "./uri.js";
|
4
|
+
export declare enum Level {
|
5
|
+
WARN = "warn",
|
6
|
+
DEBUG = "debug",
|
7
|
+
INFO = "info",
|
8
|
+
ERROR = "error"
|
9
|
+
}
|
10
|
+
export type Serialized = string | number | boolean;
|
11
|
+
export type FnSerialized = () => Serialized | Serialized[];
|
12
|
+
export declare class LogValue {
|
13
|
+
readonly fn: FnSerialized;
|
14
|
+
constructor(fn: FnSerialized);
|
15
|
+
value(): Serialized | Serialized[];
|
16
|
+
toJSON(): Serialized | Serialized[];
|
17
|
+
}
|
18
|
+
export type LogSerializable = Record<string, LogValue | Promise<LogValue>>;
|
19
|
+
export declare function removeSelfRef(lineEnd?: string): (key: unknown, val: unknown) => unknown;
|
20
|
+
export declare function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue>;
|
21
|
+
export type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;
|
22
|
+
export declare function logValue(val: LogValueArg, state?: Set<unknown>): LogValue;
|
23
|
+
export interface Sized {
|
24
|
+
size: number;
|
25
|
+
}
|
26
|
+
export interface Lengthed {
|
27
|
+
length: number;
|
28
|
+
}
|
29
|
+
export type SizeOrLength = Sized | Lengthed;
|
30
|
+
export interface LogFormatter {
|
31
|
+
format(attr: LogSerializable): Uint8Array;
|
32
|
+
}
|
33
|
+
export interface LevelHandler {
|
34
|
+
enableLevel(level: Level, ...modules: string[]): void;
|
35
|
+
disableLevel(level: Level, ...modules: string[]): void;
|
36
|
+
setExposeStack(enable?: boolean): void;
|
37
|
+
isStackExposed: boolean;
|
38
|
+
setDebug(...modules: (string | string[])[]): void;
|
39
|
+
isEnabled(ilevel: unknown, module: unknown): boolean;
|
40
|
+
}
|
41
|
+
export interface LoggerInterface<R> {
|
42
|
+
TxtEnDe(): TxtEnDecoder;
|
43
|
+
Module(key: string): R;
|
44
|
+
EnableLevel(level: Level, ...modules: string[]): R;
|
45
|
+
DisableLevel(level: Level, ...modules: string[]): R;
|
46
|
+
Attributes(): Record<string, unknown>;
|
47
|
+
SetDebug(...modules: (string | string[])[]): R;
|
48
|
+
SetExposeStack(enable?: boolean): R;
|
49
|
+
SetFormatter(fmt: LogFormatter): R;
|
50
|
+
Ref(key: string, action: {
|
51
|
+
toString: () => string;
|
52
|
+
} | FnSerialized): R;
|
53
|
+
Result<T>(key: string, res: Result<T>): R;
|
54
|
+
Url(url: CoerceURI, key?: string): R;
|
55
|
+
Len(value: unknown, key?: string): R;
|
56
|
+
Hash(value: unknown, key?: string): R;
|
57
|
+
Str(key: string, value?: string): R;
|
58
|
+
Error(): R;
|
59
|
+
Warn(): R;
|
60
|
+
Debug(): R;
|
61
|
+
Log(): R;
|
62
|
+
WithLevel(level: Level): R;
|
63
|
+
Err(err: unknown | Result<unknown> | Error): R;
|
64
|
+
Info(): R;
|
65
|
+
Timestamp(): R;
|
66
|
+
Any(key: string, value: unknown): R;
|
67
|
+
Dur(key: string, nsec: number): R;
|
68
|
+
Uint64(key: string, value: number): R;
|
69
|
+
Int(key: string, value: number): R;
|
70
|
+
Bool(key: string, value: unknown): R;
|
71
|
+
}
|
72
|
+
export declare function IsLogger(obj: unknown): obj is Logger;
|
73
|
+
export interface WithLogger extends LoggerInterface<WithLogger> {
|
74
|
+
Logger(): Logger;
|
75
|
+
}
|
76
|
+
export interface AsError {
|
77
|
+
AsError(): Error;
|
78
|
+
}
|
79
|
+
export interface Logger extends LoggerInterface<Logger> {
|
80
|
+
With(): WithLogger;
|
81
|
+
Msg(...args: string[]): AsError;
|
82
|
+
Flush(): Promise<void>;
|
83
|
+
}
|
84
|
+
//# sourceMappingURL=logger.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,oBAAY,KAAK;IACf,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AA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AClB;AAED,MAAM,WAAW,MAAO,SAAQ,eAAe,CAAC,MAAM,CAAC;IACrD,IAAI,IAAI,UAAU,CAAC;IAEnB,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/ts/logger.js
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
import { bin2string } from "./bin2text.js";
|
2
|
+
export var Level;
|
3
|
+
(function (Level) {
|
4
|
+
Level["WARN"] = "warn";
|
5
|
+
Level["DEBUG"] = "debug";
|
6
|
+
Level["INFO"] = "info";
|
7
|
+
Level["ERROR"] = "error";
|
8
|
+
})(Level || (Level = {}));
|
9
|
+
export class LogValue {
|
10
|
+
constructor(fn) {
|
11
|
+
this.fn = fn;
|
12
|
+
}
|
13
|
+
value() {
|
14
|
+
return this.fn();
|
15
|
+
}
|
16
|
+
toJSON() {
|
17
|
+
return this.value();
|
18
|
+
}
|
19
|
+
}
|
20
|
+
export function removeSelfRef(lineEnd) {
|
21
|
+
const cache = new Set();
|
22
|
+
return function (key, value) {
|
23
|
+
if (typeof value === "object" && value !== null) {
|
24
|
+
if (cache.has(value))
|
25
|
+
return "...";
|
26
|
+
cache.add(value);
|
27
|
+
}
|
28
|
+
return lineEnd ? value + lineEnd : value;
|
29
|
+
};
|
30
|
+
}
|
31
|
+
export function asyncLogValue(val) {
|
32
|
+
throw new Error("Not implemented");
|
33
|
+
}
|
34
|
+
export function logValue(val, state = new Set([Math.random()])) {
|
35
|
+
switch (typeof val) {
|
36
|
+
case "function":
|
37
|
+
return new LogValue(val);
|
38
|
+
case "string": {
|
39
|
+
try {
|
40
|
+
const ret = JSON.parse(val);
|
41
|
+
if (typeof ret === "object" && ret !== null) {
|
42
|
+
return logValue(ret, state);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
catch (e) {
|
46
|
+
if (val.match(/[\n\r]/)) {
|
47
|
+
const lines = val.trimEnd().split(/[\n\r]/);
|
48
|
+
return new LogValue(() => lines);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return new LogValue(() => val.toString());
|
52
|
+
}
|
53
|
+
case "number":
|
54
|
+
return new LogValue(() => val);
|
55
|
+
case "boolean":
|
56
|
+
return new LogValue(() => val);
|
57
|
+
case "object": {
|
58
|
+
if (ArrayBuffer.isView(val)) {
|
59
|
+
return logValue(bin2string(val, 512));
|
60
|
+
}
|
61
|
+
if (Array.isArray(val)) {
|
62
|
+
return new LogValue(() => val.map((v) => logValue(v).value()));
|
63
|
+
}
|
64
|
+
if (val === null) {
|
65
|
+
return new LogValue(() => "null");
|
66
|
+
}
|
67
|
+
if (state.has(val)) {
|
68
|
+
return new LogValue(() => "...");
|
69
|
+
}
|
70
|
+
state.add(val);
|
71
|
+
const res = {};
|
72
|
+
const typedVal = val;
|
73
|
+
for (const key in typedVal) {
|
74
|
+
const element = typedVal[key];
|
75
|
+
if (element instanceof LogValue) {
|
76
|
+
res[key] = element;
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
res[key] = logValue(element, state);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return new LogValue(() => res);
|
83
|
+
}
|
84
|
+
default:
|
85
|
+
if (!val) {
|
86
|
+
return new LogValue(() => "--Falsy--");
|
87
|
+
}
|
88
|
+
throw new Error(`Invalid type:${typeof val}`);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
export function IsLogger(obj) {
|
92
|
+
return (typeof obj === "object" &&
|
93
|
+
[
|
94
|
+
"Module",
|
95
|
+
"EnableLevel",
|
96
|
+
"DisableLevel",
|
97
|
+
"SetDebug",
|
98
|
+
"Str",
|
99
|
+
"Error",
|
100
|
+
"Warn",
|
101
|
+
"Debug",
|
102
|
+
"Log",
|
103
|
+
"WithLevel",
|
104
|
+
"Err",
|
105
|
+
"Info",
|
106
|
+
"Timestamp",
|
107
|
+
"Any",
|
108
|
+
"Dur",
|
109
|
+
"Uint64",
|
110
|
+
]
|
111
|
+
.map((fn) => typeof obj[fn] === "function")
|
112
|
+
.reduce((a, b) => a && b, true));
|
113
|
+
}
|
114
|
+
//# sourceMappingURL=logger.js.map
|
package/ts/logger.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IACf,sBAAa,CAAA;IACb,wBAAe,CAAA;IACf,sBAAa,CAAA;IACb,wBAAe,CAAA;AACjB,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAKD,MAAM,OAAO,QAAQ;IACnB,YAAqB,EAAgB;QAAhB,OAAE,GAAF,EAAE,CAAc;IAAG,CAAC;IACzC,KAAK;QACH,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC;IACnB,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF;AAID,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACxB,OAAO,UAAU,GAAY,EAAE,KAAc;QAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAEhD,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YACnC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC;AAGD,MAAM,UAAU,aAAa,CAAC,GAA8B;IAE1D,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC;AAID,MAAM,UAAU,QAAQ,CAAC,GAAgB,EAAE,QAA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