@adviser/cement 0.2.33 → 0.2.35
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +98 -32
- package/index.cjs.map +1 -1
- package/index.d.cts +10 -6
- package/index.d.ts +10 -6
- package/index.js +98 -31
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/jsr.json +1 -1
- package/src/logger-impl.ts +51 -4
- package/src/logger.ts +47 -16
- package/src/uri.ts +54 -28
- package/src/utils/stripper.ts +11 -4
- package/ts/logger-impl.d.ts +2 -0
- package/ts/logger-impl.d.ts.map +1 -1
- package/ts/logger-impl.js +49 -4
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.d.ts +2 -1
- package/ts/logger.d.ts.map +1 -1
- package/ts/logger.js +23 -15
- package/ts/logger.js.map +1 -1
- package/ts/logger.test.js +175 -0
- package/ts/logger.test.js.map +1 -1
- package/ts/uri.d.ts +5 -4
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +24 -12
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +50 -0
- package/ts/uri.test.js.map +1 -1
- package/ts/utils/stripper.d.ts +1 -1
- package/ts/utils/stripper.d.ts.map +1 -1
- package/ts/utils/stripper.js +3 -0
- package/ts/utils/stripper.js.map +1 -1
- package/ts/utils/stripper.test.js +31 -0
- package/ts/utils/stripper.test.js.map +1 -1
package/index.d.cts
CHANGED
@@ -90,12 +90,13 @@ declare class BuildURI {
|
|
90
90
|
defParam(key: string, str: string): BuildURI;
|
91
91
|
setParam(key: string, str: string): BuildURI;
|
92
92
|
hasParam(key: string): boolean;
|
93
|
-
getParam(key: string): string | undefined;
|
93
|
+
getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
|
94
94
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
95
95
|
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
96
96
|
toString(): string;
|
97
97
|
toJSON(): string;
|
98
|
-
|
98
|
+
asURL(): URL;
|
99
|
+
asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
|
99
100
|
URI(): URI;
|
100
101
|
}
|
101
102
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
@@ -116,14 +117,14 @@ declare class URI {
|
|
116
117
|
get pathname(): string;
|
117
118
|
get getParams(): Iterable<[string, string]>;
|
118
119
|
hasParam(key: string): boolean;
|
119
|
-
getParam(key: string): string | undefined;
|
120
|
+
getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
|
120
121
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
121
122
|
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
122
123
|
clone(): URI;
|
123
124
|
asURL(): URL;
|
124
125
|
toString(): string;
|
125
126
|
toJSON(): string;
|
126
|
-
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject
|
127
|
+
asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
|
127
128
|
}
|
128
129
|
|
129
130
|
declare enum Level {
|
@@ -141,7 +142,6 @@ declare class LogValue {
|
|
141
142
|
toJSON(): Serialized | Serialized[];
|
142
143
|
}
|
143
144
|
type LogSerializable = Record<string, LogValue | Promise<LogValue>>;
|
144
|
-
declare function removeSelfRef(lineEnd?: string): (key: unknown, val: unknown) => unknown;
|
145
145
|
declare function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue>;
|
146
146
|
type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;
|
147
147
|
declare function logValue(val: LogValueArg, state?: Set<unknown>): LogValue;
|
@@ -180,6 +180,8 @@ interface LoggerInterface<R> {
|
|
180
180
|
Len(value: unknown, key?: string): R;
|
181
181
|
Hash(value: unknown, key?: string): R;
|
182
182
|
Str(key: string, value?: string): R;
|
183
|
+
Http(res: Response | Result<Response>, req?: Request, key?: string): R;
|
184
|
+
Pair(x: Record<string, unknown>): R;
|
183
185
|
Error(): R;
|
184
186
|
Warn(): R;
|
185
187
|
Debug(): R;
|
@@ -268,6 +270,8 @@ declare class LoggerImpl implements Logger {
|
|
268
270
|
toString: () => string;
|
269
271
|
} | FnSerialized): Logger;
|
270
272
|
Bool(key: string, value: unknown): Logger;
|
273
|
+
Http(res: Response | Result<Response>, req?: Request, key?: string): Logger;
|
274
|
+
Pair(x: Record<string, unknown>): Logger;
|
271
275
|
Result<T>(key: string, res: Result<T, Error>): Logger;
|
272
276
|
Len(value: unknown, key?: string): Logger;
|
273
277
|
Hash(value: unknown, key?: string): Logger;
|
@@ -554,4 +558,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
554
558
|
|
555
559
|
declare const VERSION: string;
|
556
560
|
|
557
|
-
export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue,
|
561
|
+
export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
|
package/index.d.ts
CHANGED
@@ -90,12 +90,13 @@ declare class BuildURI {
|
|
90
90
|
defParam(key: string, str: string): BuildURI;
|
91
91
|
setParam(key: string, str: string): BuildURI;
|
92
92
|
hasParam(key: string): boolean;
|
93
|
-
getParam(key: string): string | undefined;
|
93
|
+
getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
|
94
94
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
95
95
|
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
96
96
|
toString(): string;
|
97
97
|
toJSON(): string;
|
98
|
-
|
98
|
+
asURL(): URL;
|
99
|
+
asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
|
99
100
|
URI(): URI;
|
100
101
|
}
|
101
102
|
type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
|
@@ -116,14 +117,14 @@ declare class URI {
|
|
116
117
|
get pathname(): string;
|
117
118
|
get getParams(): Iterable<[string, string]>;
|
118
119
|
hasParam(key: string): boolean;
|
119
|
-
getParam(key: string): string | undefined;
|
120
|
+
getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
|
120
121
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
121
122
|
getParamsResult(...keys: keysParam): Result<Record<string, string>>;
|
122
123
|
clone(): URI;
|
123
124
|
asURL(): URL;
|
124
125
|
toString(): string;
|
125
126
|
toJSON(): string;
|
126
|
-
asObj(...strips: StripCommand[]): HostURIObject | PathURIObject
|
127
|
+
asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
|
127
128
|
}
|
128
129
|
|
129
130
|
declare enum Level {
|
@@ -141,7 +142,6 @@ declare class LogValue {
|
|
141
142
|
toJSON(): Serialized | Serialized[];
|
142
143
|
}
|
143
144
|
type LogSerializable = Record<string, LogValue | Promise<LogValue>>;
|
144
|
-
declare function removeSelfRef(lineEnd?: string): (key: unknown, val: unknown) => unknown;
|
145
145
|
declare function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue>;
|
146
146
|
type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;
|
147
147
|
declare function logValue(val: LogValueArg, state?: Set<unknown>): LogValue;
|
@@ -180,6 +180,8 @@ interface LoggerInterface<R> {
|
|
180
180
|
Len(value: unknown, key?: string): R;
|
181
181
|
Hash(value: unknown, key?: string): R;
|
182
182
|
Str(key: string, value?: string): R;
|
183
|
+
Http(res: Response | Result<Response>, req?: Request, key?: string): R;
|
184
|
+
Pair(x: Record<string, unknown>): R;
|
183
185
|
Error(): R;
|
184
186
|
Warn(): R;
|
185
187
|
Debug(): R;
|
@@ -268,6 +270,8 @@ declare class LoggerImpl implements Logger {
|
|
268
270
|
toString: () => string;
|
269
271
|
} | FnSerialized): Logger;
|
270
272
|
Bool(key: string, value: unknown): Logger;
|
273
|
+
Http(res: Response | Result<Response>, req?: Request, key?: string): Logger;
|
274
|
+
Pair(x: Record<string, unknown>): Logger;
|
271
275
|
Result<T>(key: string, res: Result<T, Error>): Logger;
|
272
276
|
Len(value: unknown, key?: string): Logger;
|
273
277
|
Hash(value: unknown, key?: string): Logger;
|
@@ -554,4 +558,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
554
558
|
|
555
559
|
declare const VERSION: string;
|
556
560
|
|
557
|
-
export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue,
|
561
|
+
export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
|
package/index.js
CHANGED
@@ -101,22 +101,16 @@ var LogValue = class {
|
|
101
101
|
this.fn = fn;
|
102
102
|
}
|
103
103
|
value() {
|
104
|
-
|
104
|
+
try {
|
105
|
+
return this.fn();
|
106
|
+
} catch (e) {
|
107
|
+
return `LogValue:${e.message}`;
|
108
|
+
}
|
105
109
|
}
|
106
110
|
toJSON() {
|
107
111
|
return this.value();
|
108
112
|
}
|
109
113
|
};
|
110
|
-
function removeSelfRef(lineEnd) {
|
111
|
-
const cache = /* @__PURE__ */ new Set();
|
112
|
-
return function(key, value) {
|
113
|
-
if (typeof value === "object" && value !== null) {
|
114
|
-
if (cache.has(value)) return "...";
|
115
|
-
cache.add(value);
|
116
|
-
}
|
117
|
-
return lineEnd ? value + lineEnd : value;
|
118
|
-
};
|
119
|
-
}
|
120
114
|
function asyncLogValue(val) {
|
121
115
|
throw new Error("Not implemented");
|
122
116
|
}
|
@@ -143,19 +137,31 @@ function logValue(val, state = /* @__PURE__ */ new Set([Math.random()])) {
|
|
143
137
|
case "boolean":
|
144
138
|
return new LogValue(() => val);
|
145
139
|
case "object": {
|
140
|
+
if (val === null) {
|
141
|
+
return new LogValue(() => "null");
|
142
|
+
}
|
146
143
|
if (ArrayBuffer.isView(val)) {
|
147
144
|
return logValue(bin2string(val, 512));
|
148
145
|
}
|
149
146
|
if (Array.isArray(val)) {
|
150
147
|
return new LogValue(() => val.map((v) => logValue(v).value()));
|
151
148
|
}
|
152
|
-
if (val
|
153
|
-
return new LogValue(() =>
|
149
|
+
if (val instanceof Headers) {
|
150
|
+
return new LogValue(() => Object.fromEntries(val.entries()));
|
151
|
+
}
|
152
|
+
if (val instanceof ReadableStream) {
|
153
|
+
return new LogValue(() => ">Stream<");
|
154
|
+
}
|
155
|
+
if (val instanceof Promise) {
|
156
|
+
return new LogValue(() => ">Promise<");
|
154
157
|
}
|
155
158
|
if (state.has(val)) {
|
156
159
|
return new LogValue(() => "...");
|
157
160
|
}
|
158
161
|
state.add(val);
|
162
|
+
if (typeof val.toJSON === "function") {
|
163
|
+
return new LogValue(() => val.toJSON());
|
164
|
+
}
|
159
165
|
const res = {};
|
160
166
|
const typedVal = val;
|
161
167
|
for (const key in typedVal) {
|
@@ -163,7 +169,9 @@ function logValue(val, state = /* @__PURE__ */ new Set([Math.random()])) {
|
|
163
169
|
if (element instanceof LogValue) {
|
164
170
|
res[key] = element;
|
165
171
|
} else {
|
166
|
-
|
172
|
+
if (typeof element !== "function") {
|
173
|
+
res[key] = logValue(element, state);
|
174
|
+
}
|
167
175
|
}
|
168
176
|
}
|
169
177
|
return new LogValue(() => res);
|
@@ -297,6 +305,9 @@ function localStripper(path, restrips, obj) {
|
|
297
305
|
if (typeof obj !== "object" || obj === null) {
|
298
306
|
return obj;
|
299
307
|
}
|
308
|
+
if (Array.isArray(obj)) {
|
309
|
+
return obj.map((i) => localStripper(path, restrips, i));
|
310
|
+
}
|
300
311
|
const ret = __spreadValues({}, obj);
|
301
312
|
const matcher = (key, nextPath) => {
|
302
313
|
for (const re of restrips) {
|
@@ -555,15 +566,17 @@ var BuildURI = class _BuildURI {
|
|
555
566
|
// return this;
|
556
567
|
// }
|
557
568
|
appendRelative(p) {
|
558
|
-
const
|
559
|
-
let pathname =
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
569
|
+
const appendUrl = URI.from(p);
|
570
|
+
let pathname = appendUrl.pathname;
|
571
|
+
let basePath = this._url.pathname;
|
572
|
+
if (pathname.startsWith("/")) {
|
573
|
+
pathname = pathname.replace(/^\//, "");
|
574
|
+
}
|
575
|
+
if (basePath.length > 0) {
|
576
|
+
basePath = basePath.replace(/\/$/, "");
|
577
|
+
}
|
578
|
+
this.pathname(basePath + "/" + pathname);
|
579
|
+
for (const [key, value] of appendUrl.getParams) {
|
567
580
|
this.setParam(key, value);
|
568
581
|
}
|
569
582
|
return this;
|
@@ -585,8 +598,12 @@ var BuildURI = class _BuildURI {
|
|
585
598
|
hasParam(key) {
|
586
599
|
return this._url.searchParams.has(key);
|
587
600
|
}
|
588
|
-
getParam(key) {
|
589
|
-
|
601
|
+
getParam(key, def) {
|
602
|
+
let val = this._url.searchParams.get(key);
|
603
|
+
if (!falsy2undef(val) && def) {
|
604
|
+
val = def;
|
605
|
+
}
|
606
|
+
return falsy2undef(val);
|
590
607
|
}
|
591
608
|
getParamResult(key, msgFn) {
|
592
609
|
return getParamResult(key, this.getParam(key), msgFn);
|
@@ -601,6 +618,9 @@ var BuildURI = class _BuildURI {
|
|
601
618
|
toJSON() {
|
602
619
|
return this.toString();
|
603
620
|
}
|
621
|
+
asURL() {
|
622
|
+
return this.URI().asURL();
|
623
|
+
}
|
604
624
|
asObj(...strips) {
|
605
625
|
return this.URI().asObj(...strips);
|
606
626
|
}
|
@@ -683,8 +703,12 @@ var URI = class _URI {
|
|
683
703
|
hasParam(key) {
|
684
704
|
return this._url.searchParams.has(key);
|
685
705
|
}
|
686
|
-
getParam(key) {
|
687
|
-
|
706
|
+
getParam(key, def) {
|
707
|
+
let val = this._url.searchParams.get(key);
|
708
|
+
if (!falsy2undef(val) && def) {
|
709
|
+
val = def;
|
710
|
+
}
|
711
|
+
return falsy2undef(val);
|
688
712
|
}
|
689
713
|
getParamResult(key, msgFn) {
|
690
714
|
return getParamResult(key, this.getParam(key), msgFn);
|
@@ -905,7 +929,13 @@ var JSONFormatter = class {
|
|
905
929
|
this._space = space;
|
906
930
|
}
|
907
931
|
format(attr) {
|
908
|
-
|
932
|
+
let ret;
|
933
|
+
try {
|
934
|
+
ret = JSON.stringify(attr, null, this._space);
|
935
|
+
} catch (e) {
|
936
|
+
ret = JSON.stringify({ internal: { message: e.message, stack: e.stack } });
|
937
|
+
}
|
938
|
+
return this._txtEnDe.encode(ret + "\n");
|
909
939
|
}
|
910
940
|
};
|
911
941
|
var YAMLFormatter = class {
|
@@ -914,7 +944,7 @@ var YAMLFormatter = class {
|
|
914
944
|
this._space = space;
|
915
945
|
}
|
916
946
|
format(attr) {
|
917
|
-
return this._txtEnDe.encode("---\n" + YAML.stringify(attr,
|
947
|
+
return this._txtEnDe.encode("---\n" + YAML.stringify(attr, null, this._space) + "\n");
|
918
948
|
}
|
919
949
|
};
|
920
950
|
var LoggerImpl = class _LoggerImpl {
|
@@ -975,7 +1005,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
975
1005
|
return this._txtEnDe;
|
976
1006
|
}
|
977
1007
|
Attributes() {
|
978
|
-
return JSON.parse(JSON.stringify(this._attributes,
|
1008
|
+
return JSON.parse(JSON.stringify(this._attributes, null));
|
979
1009
|
}
|
980
1010
|
SetExposeStack(enable) {
|
981
1011
|
this._levelHandler.setExposeStack(enable);
|
@@ -1062,6 +1092,36 @@ var LoggerImpl = class _LoggerImpl {
|
|
1062
1092
|
this._attributes[key] = logValue(!!value);
|
1063
1093
|
return this;
|
1064
1094
|
}
|
1095
|
+
Http(res, req, key) {
|
1096
|
+
if (Result.Is(res)) {
|
1097
|
+
if (res.isErr()) {
|
1098
|
+
this.Err(res.Err());
|
1099
|
+
return this;
|
1100
|
+
}
|
1101
|
+
res = res.Ok();
|
1102
|
+
}
|
1103
|
+
let reqRes = res;
|
1104
|
+
if (req) {
|
1105
|
+
reqRes = { res, req };
|
1106
|
+
}
|
1107
|
+
this.Any(key || "Http", reqRes);
|
1108
|
+
return this;
|
1109
|
+
}
|
1110
|
+
Pair(x) {
|
1111
|
+
for (const key of Object.keys(x)) {
|
1112
|
+
const value = x[key];
|
1113
|
+
if (value instanceof LogValue) {
|
1114
|
+
this._attributes[key] = value;
|
1115
|
+
continue;
|
1116
|
+
}
|
1117
|
+
if (Result.Is(value)) {
|
1118
|
+
this.Result(key, value);
|
1119
|
+
continue;
|
1120
|
+
}
|
1121
|
+
this.Any(key, value);
|
1122
|
+
}
|
1123
|
+
return this;
|
1124
|
+
}
|
1065
1125
|
Result(key, res) {
|
1066
1126
|
if (res.isOk()) {
|
1067
1127
|
this._attributes[key] = logValue(res.Ok());
|
@@ -1192,6 +1252,14 @@ var WithLoggerBuilder = class {
|
|
1192
1252
|
this._li.SetDebug(...modules);
|
1193
1253
|
return this;
|
1194
1254
|
}
|
1255
|
+
Http(res, req, key) {
|
1256
|
+
this._li.Http(res, req, key);
|
1257
|
+
return this;
|
1258
|
+
}
|
1259
|
+
Pair(x) {
|
1260
|
+
this._li.Pair(x);
|
1261
|
+
return this;
|
1262
|
+
}
|
1195
1263
|
Str(key, value) {
|
1196
1264
|
this._li.Str(key, value);
|
1197
1265
|
return this;
|
@@ -1656,7 +1724,6 @@ export {
|
|
1656
1724
|
hasHostPartProtocols,
|
1657
1725
|
isURL,
|
1658
1726
|
logValue,
|
1659
|
-
removeSelfRef,
|
1660
1727
|
runtimeFn,
|
1661
1728
|
toCryptoRuntime,
|
1662
1729
|
utils_exports as utils
|