@bitblit/ratchet-common 4.0.99-alpha → 4.0.102-alpha
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/dist/{types/2d → 2d}/line-2d.d.ts +1 -1
- package/dist/{types/2d → 2d}/poly-line-2d.d.ts +1 -1
- package/dist/{types/2d → 2d}/ratchet-2d.d.ts +4 -4
- package/dist/{es/2d → 2d}/ratchet-2d.js +1 -1
- package/dist/2d/ratchet-2d.spec.js +117 -0
- package/dist/{types/build → build}/ratchet-common-info.d.ts +1 -1
- package/dist/{types/histogram → histogram}/histogram.d.ts +1 -4
- package/dist/{es/histogram → histogram}/histogram.js +1 -3
- package/dist/histogram/histogram.spec.js +19 -0
- package/dist/jwt/common-jwt-token.d.ts +6 -0
- package/dist/{types/jwt → jwt}/jwt-ratchet-like.d.ts +3 -6
- package/dist/{types/jwt → jwt}/jwt-ratchet.d.ts +4 -13
- package/dist/{es/jwt → jwt}/jwt-ratchet.js +12 -7
- package/dist/jwt/jwt-ratchet.spec.js +49 -0
- package/dist/{types/jwt → jwt}/jwt-token-base.d.ts +0 -4
- package/dist/lang/array-ratchet.d.ts +14 -0
- package/dist/{es/lang → lang}/array-ratchet.js +2 -2
- package/dist/lang/array-ratchet.spec.js +68 -0
- package/dist/{types/lang → lang}/base64-ratchet.d.ts +1 -1
- package/dist/{es/lang → lang}/base64-ratchet.js +1 -1
- package/dist/lang/base64-ratchet.spec.js +28 -0
- package/dist/{es/lang → lang}/boolean-ratchet.js +1 -1
- package/dist/lang/boolean-ratchet.spec.js +81 -0
- package/dist/{types/lang → lang}/composite-last-success-provider.d.ts +1 -2
- package/dist/{es/lang → lang}/composite-last-success-provider.js +2 -0
- package/dist/lang/composite-last-success-provider.spec.js +26 -0
- package/dist/{es/lang → lang}/date-ratchet.js +5 -5
- package/dist/lang/date-ratchet.spec.js +21 -0
- package/dist/{es/lang → lang}/duration-ratchet.js +1 -1
- package/dist/lang/duration-ratchet.spec.js +39 -0
- package/dist/lang/enum-ratchet.d.ts +5 -0
- package/dist/{es/lang → lang}/enum-ratchet.js +1 -1
- package/dist/lang/enum-ratchet.spec.d.ts +5 -0
- package/dist/lang/enum-ratchet.spec.js +31 -0
- package/dist/{es/lang → lang}/error-ratchet.js +1 -1
- package/dist/lang/error-ratchet.spec.js +20 -0
- package/dist/lang/esm-ratchet.d.ts +4 -0
- package/dist/lang/esm-ratchet.js +11 -0
- package/dist/{types/lang → lang}/expiring-object.d.ts +1 -1
- package/dist/{es/lang → lang}/expiring-object.js +13 -4
- package/dist/lang/expiring-object.spec.js +51 -0
- package/dist/{es/lang → lang}/geolocation-ratchet.js +4 -4
- package/dist/lang/geolocation-ratchet.spec.d.ts +1 -0
- package/dist/lang/geolocation-ratchet.spec.js +74 -0
- package/dist/{es/lang → lang}/global-ratchet.js +3 -3
- package/dist/lang/global-ratchet.spec.d.ts +1 -0
- package/dist/lang/global-ratchet.spec.js +14 -0
- package/dist/{es/lang → lang}/key-value.js +2 -0
- package/dist/lang/last-success-provider.d.ts +3 -0
- package/dist/lang/last-success-provider.js +1 -0
- package/dist/{types/lang → lang}/map-ratchet.d.ts +1 -1
- package/dist/{es/lang → lang}/map-ratchet.js +3 -3
- package/dist/lang/map-ratchet.spec.d.ts +1 -0
- package/dist/lang/map-ratchet.spec.js +90 -0
- package/dist/lang/no.spec.d.ts +1 -0
- package/dist/lang/no.spec.js +7 -0
- package/dist/{es/lang → lang}/number-ratchet.js +3 -3
- package/dist/lang/number-ratchet.spec.d.ts +1 -0
- package/dist/lang/number-ratchet.spec.js +118 -0
- package/dist/lang/parsed-url.js +1 -0
- package/dist/lang/promise-ratchet.d.ts +18 -0
- package/dist/{es/lang → lang}/promise-ratchet.js +5 -5
- package/dist/lang/promise-ratchet.spec.d.ts +1 -0
- package/dist/lang/promise-ratchet.spec.js +74 -0
- package/dist/{es/lang → lang}/require-ratchet.js +1 -1
- package/dist/lang/require-ratchet.spec.d.ts +3 -0
- package/dist/lang/require-ratchet.spec.js +80 -0
- package/dist/{types/lang → lang}/stop-watch.d.ts +1 -1
- package/dist/{es/lang → lang}/stop-watch.js +9 -8
- package/dist/{es/lang → lang}/string-ratchet.js +2 -2
- package/dist/lang/string-ratchet.spec.d.ts +1 -0
- package/dist/lang/string-ratchet.spec.js +158 -0
- package/dist/lang/time-zone-ratchet.d.ts +19 -0
- package/dist/{es/lang → lang}/time-zone-ratchet.js +2 -1
- package/dist/lang/time-zone-ratchet.spec.d.ts +1 -0
- package/dist/lang/time-zone-ratchet.spec.js +40 -0
- package/dist/{types/lang → lang}/timeout-token.d.ts +1 -1
- package/dist/{es/lang → lang}/timeout-token.js +5 -3
- package/dist/lang/timeout-token.spec.d.ts +1 -0
- package/dist/lang/timeout-token.spec.js +9 -0
- package/dist/{types/lang → lang}/transform-ratchet.d.ts +1 -1
- package/dist/{es/lang → lang}/transform-ratchet.js +1 -1
- package/dist/lang/transform-ratchet.spec.d.ts +1 -0
- package/dist/lang/transform-ratchet.spec.js +118 -0
- package/dist/logger/classic-single-line-log-message-formatter.d.ts +6 -0
- package/dist/{types/logger → logger}/log-message-builder.d.ts +2 -2
- package/dist/{es/logger → logger}/log-message-builder.js +1 -0
- package/dist/{types/logger → logger}/log-message-formatter.d.ts +2 -2
- package/dist/logger/log-message-formatter.js +1 -0
- package/dist/{types/logger → logger}/log-message-processor.d.ts +1 -1
- package/dist/logger/log-message-processor.js +1 -0
- package/dist/{types/logger → logger}/log-message.d.ts +1 -1
- package/dist/logger/log-message.js +1 -0
- package/dist/{types/logger → logger}/log-snapshot.d.ts +1 -1
- package/dist/logger/log-snapshot.js +1 -0
- package/dist/{types/logger → logger}/logger-instance.d.ts +6 -6
- package/dist/{es/logger → logger}/logger-instance.js +15 -8
- package/dist/{types/logger → logger}/logger-meta.d.ts +1 -1
- package/dist/logger/logger-meta.js +1 -0
- package/dist/{types/logger → logger}/logger-options.d.ts +4 -4
- package/dist/logger/logger-options.js +1 -0
- package/dist/{types/logger → logger}/logger-ring-buffer.d.ts +2 -2
- package/dist/{es/logger → logger}/logger-ring-buffer.js +7 -6
- package/dist/{types/logger → logger}/logger-util.d.ts +2 -2
- package/dist/{es/logger → logger}/logger-util.js +10 -10
- package/dist/logger/logger-util.spec.d.ts +1 -0
- package/dist/logger/logger-util.spec.js +9 -0
- package/dist/{types/logger → logger}/logger.d.ts +7 -16
- package/dist/{es/logger → logger}/logger.js +14 -14
- package/dist/logger/logger.spec.d.ts +1 -0
- package/dist/logger/logger.spec.js +134 -0
- package/dist/logger/none-log-message-formatter.d.ts +6 -0
- package/dist/logger/structured-json-log-message-formatter.d.ts +6 -0
- package/dist/{types/network → network}/browser-local-ip-provider.d.ts +1 -1
- package/dist/{es/network → network}/browser-local-ip-provider.js +3 -3
- package/dist/network/browser-local-ip-provider.spec.d.ts +1 -0
- package/dist/network/browser-local-ip-provider.spec.js +16 -0
- package/dist/{types/network → network}/fixed-local-ip-provider.d.ts +1 -1
- package/dist/{es/network → network}/fixed-local-ip-provider.js +1 -0
- package/dist/network/local-ip-provider.d.ts +3 -0
- package/dist/network/local-ip-provider.js +1 -0
- package/dist/{types/network → network}/network-ratchet.d.ts +1 -1
- package/dist/{es/network → network}/network-ratchet.js +2 -2
- package/dist/network/network-ratchet.spec.d.ts +1 -0
- package/dist/network/network-ratchet.spec.js +13 -0
- package/dist/{types/stream → stream}/buffer-writable.d.ts +2 -2
- package/dist/{es/stream → stream}/buffer-writable.js +1 -1
- package/dist/stream/multi-stream.d.ts +7 -0
- package/dist/stream/multi-stream.js +12 -0
- package/dist/{types/stream → stream}/stream-ratchet.d.ts +2 -2
- package/dist/{es/stream → stream}/stream-ratchet.js +2 -2
- package/dist/stream/stream-ratchet.spec.d.ts +1 -0
- package/dist/stream/stream-ratchet.spec.js +13 -0
- package/dist/{types/stream → stream}/string-writable.d.ts +1 -1
- package/dist/{es/stream → stream}/string-writable.js +1 -1
- package/dist/stream/string-writable.spec.d.ts +1 -0
- package/dist/stream/string-writable.spec.js +12 -0
- package/dist/{es/third-party → third-party}/google/google-recaptcha-ratchet.js +3 -3
- package/dist/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
- package/dist/third-party/google/google-recaptcha-ratchet.spec.js +20 -0
- package/dist/{types/third-party → third-party}/twilio/twilio-ratchet.d.ts +0 -4
- package/dist/{es/third-party → third-party}/twilio/twilio-ratchet.js +8 -5
- package/dist/{types/transform → transform}/built-in-transforms.d.ts +1 -1
- package/dist/{es/transform → transform}/built-in-transforms.js +2 -2
- package/dist/transform/transform-rule.js +1 -0
- package/dist/{types/tx → tx}/transaction-configuration.d.ts +2 -2
- package/dist/tx/transaction-configuration.js +1 -0
- package/dist/{types/tx → tx}/transaction-ratchet.d.ts +3 -3
- package/dist/{es/tx → tx}/transaction-ratchet.js +4 -4
- package/dist/tx/transaction-ratchet.spec.d.ts +1 -0
- package/dist/tx/transaction-ratchet.spec.js +130 -0
- package/dist/{types/tx → tx}/transaction-result.d.ts +1 -1
- package/dist/tx/transaction-result.js +1 -0
- package/dist/tx/transaction-step.js +1 -0
- package/package.json +10 -11
- package/dist/cjs/2d/line-2d.js +0 -2
- package/dist/cjs/2d/plane-2d.js +0 -2
- package/dist/cjs/2d/point-2d.js +0 -2
- package/dist/cjs/2d/poly-line-2d.js +0 -2
- package/dist/cjs/2d/ratchet-2d.js +0 -250
- package/dist/cjs/build/build-information.js +0 -2
- package/dist/cjs/build/ratchet-common-info.js +0 -18
- package/dist/cjs/histogram/histogram-entry.js +0 -2
- package/dist/cjs/histogram/histogram.js +0 -54
- package/dist/cjs/index.js +0 -74
- package/dist/cjs/jwt/common-jwt-token.js +0 -2
- package/dist/cjs/jwt/expired-jwt-handling.js +0 -9
- package/dist/cjs/jwt/jwt-ratchet-like.js +0 -2
- package/dist/cjs/jwt/jwt-ratchet.js +0 -164
- package/dist/cjs/jwt/jwt-token-base.js +0 -2
- package/dist/cjs/lang/array-ratchet.js +0 -87
- package/dist/cjs/lang/base64-ratchet.js +0 -49
- package/dist/cjs/lang/boolean-ratchet.js +0 -49
- package/dist/cjs/lang/composite-last-success-provider.js +0 -28
- package/dist/cjs/lang/date-ratchet.js +0 -33
- package/dist/cjs/lang/duration-ratchet.js +0 -46
- package/dist/cjs/lang/enum-ratchet.js +0 -34
- package/dist/cjs/lang/error-ratchet.js +0 -49
- package/dist/cjs/lang/expiring-object.js +0 -68
- package/dist/cjs/lang/geolocation-ratchet.js +0 -267
- package/dist/cjs/lang/global-ratchet.js +0 -48
- package/dist/cjs/lang/key-value.js +0 -6
- package/dist/cjs/lang/last-success-provider.js +0 -2
- package/dist/cjs/lang/map-ratchet.js +0 -168
- package/dist/cjs/lang/no.js +0 -8
- package/dist/cjs/lang/number-ratchet.js +0 -159
- package/dist/cjs/lang/parsed-url.js +0 -2
- package/dist/cjs/lang/promise-ratchet.js +0 -142
- package/dist/cjs/lang/require-ratchet.js +0 -60
- package/dist/cjs/lang/stop-watch.js +0 -117
- package/dist/cjs/lang/string-ratchet.js +0 -195
- package/dist/cjs/lang/time-zone-ratchet.js +0 -80
- package/dist/cjs/lang/timeout-token.js +0 -19
- package/dist/cjs/lang/transform-ratchet.js +0 -70
- package/dist/cjs/logger/classic-single-line-log-message-formatter.js +0 -18
- package/dist/cjs/logger/log-message-builder.js +0 -51
- package/dist/cjs/logger/log-message-format-type.js +0 -9
- package/dist/cjs/logger/log-message-formatter.js +0 -2
- package/dist/cjs/logger/log-message-processor.js +0 -2
- package/dist/cjs/logger/log-message.js +0 -2
- package/dist/cjs/logger/log-snapshot.js +0 -2
- package/dist/cjs/logger/logger-instance.js +0 -207
- package/dist/cjs/logger/logger-level-name.js +0 -12
- package/dist/cjs/logger/logger-meta.js +0 -2
- package/dist/cjs/logger/logger-options.js +0 -2
- package/dist/cjs/logger/logger-output-function.js +0 -9
- package/dist/cjs/logger/logger-ring-buffer.js +0 -76
- package/dist/cjs/logger/logger-util.js +0 -49
- package/dist/cjs/logger/logger.js +0 -139
- package/dist/cjs/logger/none-log-message-formatter.js +0 -9
- package/dist/cjs/logger/structured-json-log-message-formatter.js +0 -24
- package/dist/cjs/network/browser-local-ip-provider.js +0 -25
- package/dist/cjs/network/fixed-local-ip-provider.js +0 -12
- package/dist/cjs/network/local-ip-provider.js +0 -2
- package/dist/cjs/network/network-ratchet.js +0 -106
- package/dist/cjs/stream/buffer-writable.js +0 -20
- package/dist/cjs/stream/stream-ratchet.js +0 -72
- package/dist/cjs/stream/string-writable.js +0 -18
- package/dist/cjs/third-party/google/google-recaptcha-ratchet.js +0 -33
- package/dist/cjs/third-party/twilio/twilio-ratchet.js +0 -75
- package/dist/cjs/transform/built-in-transforms.js +0 -195
- package/dist/cjs/transform/transform-rule.js +0 -2
- package/dist/cjs/tx/transaction-configuration.js +0 -2
- package/dist/cjs/tx/transaction-final-state.js +0 -9
- package/dist/cjs/tx/transaction-ratchet.js +0 -80
- package/dist/cjs/tx/transaction-result.js +0 -2
- package/dist/cjs/tx/transaction-step.js +0 -2
- package/dist/es/index.js +0 -71
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.es.tsbuildinfo +0 -1
- package/dist/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -74
- package/dist/types/jwt/common-jwt-token.d.ts +0 -17
- package/dist/types/lang/array-ratchet.d.ts +0 -30
- package/dist/types/lang/enum-ratchet.d.ts +0 -12
- package/dist/types/lang/last-success-provider.d.ts +0 -4
- package/dist/types/lang/promise-ratchet.d.ts +0 -32
- package/dist/types/lang/time-zone-ratchet.d.ts +0 -50
- package/dist/types/logger/classic-single-line-log-message-formatter.d.ts +0 -6
- package/dist/types/logger/none-log-message-formatter.d.ts +0 -6
- package/dist/types/logger/structured-json-log-message-formatter.d.ts +0 -6
- package/dist/types/network/local-ip-provider.d.ts +0 -4
- /package/dist/{es/2d → 2d}/line-2d.js +0 -0
- /package/dist/{types/2d → 2d}/plane-2d.d.ts +0 -0
- /package/dist/{es/2d → 2d}/plane-2d.js +0 -0
- /package/dist/{types/2d → 2d}/point-2d.d.ts +0 -0
- /package/dist/{es/2d → 2d}/point-2d.js +0 -0
- /package/dist/{es/2d → 2d}/poly-line-2d.js +0 -0
- /package/dist/{es/build/build-information.js → 2d/ratchet-2d.spec.d.ts} +0 -0
- /package/dist/{types/build → build}/build-information.d.ts +0 -0
- /package/dist/{es/histogram/histogram-entry.js → build/build-information.js} +0 -0
- /package/dist/{es/build → build}/ratchet-common-info.js +0 -0
- /package/dist/{types/histogram → histogram}/histogram-entry.d.ts +0 -0
- /package/dist/{es/jwt/common-jwt-token.js → histogram/histogram-entry.js} +0 -0
- /package/dist/{es/jwt/jwt-ratchet-like.js → histogram/histogram.spec.d.ts} +0 -0
- /package/dist/{es/jwt/jwt-token-base.js → index.d.ts} +0 -0
- /package/dist/{es/lang/last-success-provider.js → index.js} +0 -0
- /package/dist/{es/lang/parsed-url.js → jwt/common-jwt-token.js} +0 -0
- /package/dist/{types/jwt → jwt}/expired-jwt-handling.d.ts +0 -0
- /package/dist/{es/jwt → jwt}/expired-jwt-handling.js +0 -0
- /package/dist/{es/logger/log-message-formatter.js → jwt/jwt-ratchet-like.js} +0 -0
- /package/dist/{es/logger/log-message-processor.js → jwt/jwt-ratchet.spec.d.ts} +0 -0
- /package/dist/{es/logger/log-message.js → jwt/jwt-token-base.js} +0 -0
- /package/dist/{es/logger/log-snapshot.js → lang/array-ratchet.spec.d.ts} +0 -0
- /package/dist/{es/logger/logger-meta.js → lang/base64-ratchet.spec.d.ts} +0 -0
- /package/dist/{types/lang → lang}/boolean-ratchet.d.ts +0 -0
- /package/dist/{es/logger/logger-options.js → lang/boolean-ratchet.spec.d.ts} +0 -0
- /package/dist/{es/network/local-ip-provider.js → lang/composite-last-success-provider.spec.d.ts} +0 -0
- /package/dist/{types/lang → lang}/date-ratchet.d.ts +0 -0
- /package/dist/{es/transform/transform-rule.js → lang/date-ratchet.spec.d.ts} +0 -0
- /package/dist/{types/lang → lang}/duration-ratchet.d.ts +0 -0
- /package/dist/{es/tx/transaction-configuration.js → lang/duration-ratchet.spec.d.ts} +0 -0
- /package/dist/{types/lang → lang}/error-ratchet.d.ts +0 -0
- /package/dist/{es/tx/transaction-result.js → lang/error-ratchet.spec.d.ts} +0 -0
- /package/dist/{es/tx/transaction-step.js → lang/expiring-object.spec.d.ts} +0 -0
- /package/dist/{types/lang → lang}/geolocation-ratchet.d.ts +0 -0
- /package/dist/{types/lang → lang}/global-ratchet.d.ts +0 -0
- /package/dist/{types/lang → lang}/key-value.d.ts +0 -0
- /package/dist/{types/lang → lang}/no.d.ts +0 -0
- /package/dist/{es/lang → lang}/no.js +0 -0
- /package/dist/{types/lang → lang}/number-ratchet.d.ts +0 -0
- /package/dist/{types/lang → lang}/parsed-url.d.ts +0 -0
- /package/dist/{types/lang → lang}/require-ratchet.d.ts +0 -0
- /package/dist/{types/lang → lang}/string-ratchet.d.ts +0 -0
- /package/dist/{es/logger → logger}/classic-single-line-log-message-formatter.js +0 -0
- /package/dist/{types/logger → logger}/log-message-format-type.d.ts +0 -0
- /package/dist/{es/logger → logger}/log-message-format-type.js +0 -0
- /package/dist/{types/logger → logger}/logger-level-name.d.ts +0 -0
- /package/dist/{es/logger → logger}/logger-level-name.js +0 -0
- /package/dist/{types/logger → logger}/logger-output-function.d.ts +0 -0
- /package/dist/{es/logger → logger}/logger-output-function.js +0 -0
- /package/dist/{es/logger → logger}/none-log-message-formatter.js +0 -0
- /package/dist/{es/logger → logger}/structured-json-log-message-formatter.js +0 -0
- /package/dist/{types/third-party → third-party}/google/google-recaptcha-ratchet.d.ts +0 -0
- /package/dist/{types/transform → transform}/transform-rule.d.ts +0 -0
- /package/dist/{types/tx → tx}/transaction-final-state.d.ts +0 -0
- /package/dist/{es/tx → tx}/transaction-final-state.js +0 -0
- /package/dist/{types/tx → tx}/transaction-step.d.ts +0 -0
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeZoneRatchet = void 0;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
|
-
class TimeZoneRatchet {
|
|
6
|
-
constructor(timezone) {
|
|
7
|
-
if (!timezone) {
|
|
8
|
-
throw 'Timezone cannot be null';
|
|
9
|
-
}
|
|
10
|
-
this.timezone = timezone;
|
|
11
|
-
}
|
|
12
|
-
currentHour() {
|
|
13
|
-
const rval = luxon_1.DateTime.local().setZone(this.timezone).hour;
|
|
14
|
-
return rval;
|
|
15
|
-
}
|
|
16
|
-
toEpochSeconds(dt) {
|
|
17
|
-
return Math.round(dt.toMillis() / 1000);
|
|
18
|
-
}
|
|
19
|
-
startOfTodayEpochSeconds() {
|
|
20
|
-
const startOfToday = this.toEpochSeconds(luxon_1.DateTime.local().setZone(this.timezone).set({ hour: 0, minute: 0, second: 0, millisecond: 0 }));
|
|
21
|
-
return startOfToday;
|
|
22
|
-
}
|
|
23
|
-
startOfMatchingDayEpochSeconds(inputTS) {
|
|
24
|
-
const startOfToday = this.toEpochSeconds(luxon_1.DateTime.fromMillis(inputTS).set({ hour: 0, minute: 0, second: 0, millisecond: 0 }));
|
|
25
|
-
return startOfToday;
|
|
26
|
-
}
|
|
27
|
-
startOfMatchingDayEpochMS(inputTS) {
|
|
28
|
-
return this.startOfMatchingDayEpochSeconds(inputTS) * 1000;
|
|
29
|
-
}
|
|
30
|
-
startOfCurrentHourEpochSeconds() {
|
|
31
|
-
const rval = this.toEpochSeconds(luxon_1.DateTime.local().setZone(this.timezone).set({ minute: 0, second: 0, millisecond: 0 }));
|
|
32
|
-
return rval;
|
|
33
|
-
}
|
|
34
|
-
startOfCurrentMinuteEpochSeconds() {
|
|
35
|
-
const rval = this.toEpochSeconds(luxon_1.DateTime.local().setZone(this.timezone).set({ second: 0, millisecond: 0 }));
|
|
36
|
-
return rval;
|
|
37
|
-
}
|
|
38
|
-
startOfCurrentSecondEpochSeconds() {
|
|
39
|
-
const rval = this.toEpochSeconds(luxon_1.DateTime.local().setZone(this.timezone).set({ millisecond: 0 }));
|
|
40
|
-
return rval;
|
|
41
|
-
}
|
|
42
|
-
startOfTodayEpochMS() {
|
|
43
|
-
const startOfToday = luxon_1.DateTime.local().setZone(this.timezone).set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).toMillis();
|
|
44
|
-
return startOfToday;
|
|
45
|
-
}
|
|
46
|
-
dailySlotCount(slotWidthMs) {
|
|
47
|
-
return Math.ceil(86400000 / slotWidthMs);
|
|
48
|
-
}
|
|
49
|
-
currentTimeSlotIdx(slotWidthMs) {
|
|
50
|
-
if (slotWidthMs < 1) {
|
|
51
|
-
throw new Error('Cannot process with slot less than one ms wide');
|
|
52
|
-
}
|
|
53
|
-
const startOfToday = this.startOfTodayEpochMS();
|
|
54
|
-
const now = new Date().getTime();
|
|
55
|
-
const delta = now - startOfToday;
|
|
56
|
-
const idx = Math.floor(delta / slotWidthMs);
|
|
57
|
-
return idx;
|
|
58
|
-
}
|
|
59
|
-
matchingTimeSlotIdx(timestamp, slotWidthMs) {
|
|
60
|
-
if (slotWidthMs < 1) {
|
|
61
|
-
throw new Error('Cannot process with slot less than one ms wide');
|
|
62
|
-
}
|
|
63
|
-
const startOfDay = this.startOfMatchingDayEpochMS(timestamp);
|
|
64
|
-
const delta = timestamp - startOfDay;
|
|
65
|
-
const idx = Math.floor(delta / slotWidthMs);
|
|
66
|
-
return idx;
|
|
67
|
-
}
|
|
68
|
-
startOfCurrentSlotEpochMS(slotWidthMs) {
|
|
69
|
-
const startOfToday = this.startOfTodayEpochMS();
|
|
70
|
-
const currentIdx = this.currentTimeSlotIdx(slotWidthMs);
|
|
71
|
-
return startOfToday + currentIdx * slotWidthMs;
|
|
72
|
-
}
|
|
73
|
-
startOfMatchingSlotEpochMS(timestamp, slotWidthMs) {
|
|
74
|
-
const startOfDay = this.startOfMatchingDayEpochMS(timestamp);
|
|
75
|
-
const currentIdx = this.matchingTimeSlotIdx(timestamp, slotWidthMs);
|
|
76
|
-
return startOfDay + currentIdx * slotWidthMs;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.TimeZoneRatchet = TimeZoneRatchet;
|
|
80
|
-
TimeZoneRatchet.PACIFIC = new TimeZoneRatchet('America/Los_Angeles');
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeoutToken = void 0;
|
|
4
|
-
const logger_1 = require("../logger/logger");
|
|
5
|
-
const logger_level_name_1 = require("../logger/logger-level-name");
|
|
6
|
-
class TimeoutToken {
|
|
7
|
-
constructor(title, timeoutMS) {
|
|
8
|
-
this.title = title;
|
|
9
|
-
this.timeoutMS = timeoutMS;
|
|
10
|
-
this.__timeoutTokenFlagField = true;
|
|
11
|
-
}
|
|
12
|
-
writeToLog(logLevel = logger_level_name_1.LoggerLevelName.warn) {
|
|
13
|
-
logger_1.Logger.logByLevel(logLevel, 'Timed out after %d ms waiting for results of %s', this.timeoutMS, this.title);
|
|
14
|
-
}
|
|
15
|
-
static isTimeoutToken(value) {
|
|
16
|
-
return !!value && !!value['__timeoutTokenFlagField'];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.TimeoutToken = TimeoutToken;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransformRatchet = void 0;
|
|
4
|
-
const logger_1 = require("../logger/logger");
|
|
5
|
-
class TransformRatchet {
|
|
6
|
-
static transform(toTransform, rules = []) {
|
|
7
|
-
return TransformRatchet.transformGeneric(toTransform, rules, false, null);
|
|
8
|
-
}
|
|
9
|
-
static transformGeneric(toTransform, rules = [], isKey, context) {
|
|
10
|
-
let rval = null;
|
|
11
|
-
const type = typeof toTransform;
|
|
12
|
-
switch (type) {
|
|
13
|
-
case 'undefined':
|
|
14
|
-
case 'symbol':
|
|
15
|
-
case 'function':
|
|
16
|
-
rval = toTransform;
|
|
17
|
-
break;
|
|
18
|
-
case 'number':
|
|
19
|
-
case 'string':
|
|
20
|
-
case 'boolean':
|
|
21
|
-
rval = TransformRatchet.applyTransformToPrimitive(toTransform, rules, isKey, context);
|
|
22
|
-
break;
|
|
23
|
-
case 'object':
|
|
24
|
-
rval = TransformRatchet.applyTransformToObject(toTransform, rules, isKey, context);
|
|
25
|
-
break;
|
|
26
|
-
default:
|
|
27
|
-
throw new Error('Unrecognized type ' + type);
|
|
28
|
-
}
|
|
29
|
-
return rval;
|
|
30
|
-
}
|
|
31
|
-
static applyTransformToObject(toTransform, rules = [], isKey, context = null) {
|
|
32
|
-
logger_1.Logger.silly('Tranform: %j, %s, %j', toTransform, isKey, context);
|
|
33
|
-
let rval = null;
|
|
34
|
-
if (toTransform != null) {
|
|
35
|
-
if (Array.isArray(toTransform)) {
|
|
36
|
-
rval = [];
|
|
37
|
-
toTransform.forEach((val) => {
|
|
38
|
-
const newVal = TransformRatchet.transformGeneric(val, rules, isKey, toTransform);
|
|
39
|
-
if (newVal != null) {
|
|
40
|
-
rval.push(newVal);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
rval = {};
|
|
46
|
-
Object.keys(toTransform).forEach((k) => {
|
|
47
|
-
const oldValue = toTransform[k];
|
|
48
|
-
const newKey = TransformRatchet.applyTransformToPrimitive(k, rules, true, toTransform);
|
|
49
|
-
if (newKey != null) {
|
|
50
|
-
let newValue = TransformRatchet.transformGeneric(oldValue, rules, false, toTransform);
|
|
51
|
-
newValue = TransformRatchet.applyTransformToPrimitive(newValue, rules, false, toTransform);
|
|
52
|
-
if (newValue != null) {
|
|
53
|
-
rval[newKey] = newValue;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
rval = TransformRatchet.applyTransformToPrimitive(rval, rules, false, toTransform);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return rval;
|
|
61
|
-
}
|
|
62
|
-
static applyTransformToPrimitive(toTransform, rules = [], isKey, context) {
|
|
63
|
-
let rval = toTransform;
|
|
64
|
-
rules.forEach((r) => {
|
|
65
|
-
rval = rval == null ? null : r.transform(rval, isKey, context);
|
|
66
|
-
});
|
|
67
|
-
return rval;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.TransformRatchet = TransformRatchet;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClassicSingleLineLogMessageFormatter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const util_1 = tslib_1.__importDefault(require("util"));
|
|
6
|
-
class ClassicSingleLineLogMessageFormatter {
|
|
7
|
-
formatMessage(msg, meta) {
|
|
8
|
-
let tmp = null;
|
|
9
|
-
if (msg) {
|
|
10
|
-
tmp = '';
|
|
11
|
-
tmp += meta.options.trace ? meta.options.trace + ' ' : '';
|
|
12
|
-
tmp += '[' + msg.lvl + '] ';
|
|
13
|
-
tmp += util_1.default.format(msg.messageSource, ...msg.subsVars);
|
|
14
|
-
}
|
|
15
|
-
return tmp;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ClassicSingleLineLogMessageFormatter = ClassicSingleLineLogMessageFormatter;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogMessageBuilder = void 0;
|
|
4
|
-
class LogMessageBuilder {
|
|
5
|
-
constructor(lvl, messageSource) {
|
|
6
|
-
if (!lvl) {
|
|
7
|
-
throw Error('Cannot set level to null/undefined');
|
|
8
|
-
}
|
|
9
|
-
this.wrapped = { lvl: lvl, timestamp: Date.now(), messageSource: messageSource };
|
|
10
|
-
}
|
|
11
|
-
clone() {
|
|
12
|
-
const rval = new LogMessageBuilder(this.wrapped.lvl, this.wrapped.messageSource);
|
|
13
|
-
rval.wrapped = Object.assign({}, this.wrapped);
|
|
14
|
-
return rval;
|
|
15
|
-
}
|
|
16
|
-
level(lvl) {
|
|
17
|
-
if (!lvl) {
|
|
18
|
-
throw Error('Cannot set level to null/undefined');
|
|
19
|
-
}
|
|
20
|
-
this.wrapped.lvl = lvl;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
timestamp(val) {
|
|
24
|
-
if (!val) {
|
|
25
|
-
throw Error('Cannot set timestamp to null/undefined');
|
|
26
|
-
}
|
|
27
|
-
this.wrapped.timestamp = val;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
messageSource(val) {
|
|
31
|
-
this.wrapped.messageSource = val;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
subVars(val) {
|
|
35
|
-
this.wrapped.subsVars = val || [];
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
params(val) {
|
|
39
|
-
this.wrapped.params = val || {};
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
p(name, value) {
|
|
43
|
-
this.wrapped.params = this.wrapped.params || {};
|
|
44
|
-
this.wrapped.params[name] = value;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
toMessage() {
|
|
48
|
-
return Object.assign({}, this.wrapped);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.LogMessageBuilder = LogMessageBuilder;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogMessageFormatType = void 0;
|
|
4
|
-
var LogMessageFormatType;
|
|
5
|
-
(function (LogMessageFormatType) {
|
|
6
|
-
LogMessageFormatType["ClassicSingleLine"] = "ClassicSingleLine";
|
|
7
|
-
LogMessageFormatType["StructuredJson"] = "StructuredJson";
|
|
8
|
-
LogMessageFormatType["None"] = "None";
|
|
9
|
-
})(LogMessageFormatType = exports.LogMessageFormatType || (exports.LogMessageFormatType = {}));
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerInstance = void 0;
|
|
4
|
-
const logger_ring_buffer_1 = require("./logger-ring-buffer");
|
|
5
|
-
const logger_level_name_1 = require("./logger-level-name");
|
|
6
|
-
const logger_util_1 = require("./logger-util");
|
|
7
|
-
const log_message_format_type_1 = require("./log-message-format-type");
|
|
8
|
-
const classic_single_line_log_message_formatter_1 = require("./classic-single-line-log-message-formatter");
|
|
9
|
-
const none_log_message_formatter_1 = require("./none-log-message-formatter");
|
|
10
|
-
const structured_json_log_message_formatter_1 = require("./structured-json-log-message-formatter");
|
|
11
|
-
const string_ratchet_1 = require("../lang/string-ratchet");
|
|
12
|
-
class LoggerInstance {
|
|
13
|
-
constructor(loggerInstanceName = 'default', inOptions) {
|
|
14
|
-
this.loggerInstanceName = loggerInstanceName;
|
|
15
|
-
this.options = inOptions;
|
|
16
|
-
}
|
|
17
|
-
addPreProcessor(proc) {
|
|
18
|
-
if (proc) {
|
|
19
|
-
this._options.preProcessors = this._options.preProcessors || [];
|
|
20
|
-
this._options.preProcessors.push(proc);
|
|
21
|
-
}
|
|
22
|
-
return Object.assign([], this._options.preProcessors);
|
|
23
|
-
}
|
|
24
|
-
get ringBuffer() {
|
|
25
|
-
return this._ringBuffer;
|
|
26
|
-
}
|
|
27
|
-
dumpConfigurationIntoLog() {
|
|
28
|
-
this.error('ERROR enabled');
|
|
29
|
-
this.warn('WARN enabled');
|
|
30
|
-
this.info('INFO enabled');
|
|
31
|
-
this.verbose('VERBOSE enabled');
|
|
32
|
-
this.debug('DEBUG enabled');
|
|
33
|
-
this.silly('SILLY enabled');
|
|
34
|
-
}
|
|
35
|
-
dumpOptionsIntoLog() {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
this.info('Options: %j', this.options);
|
|
38
|
-
if ((_b = (_a = this === null || this === void 0 ? void 0 : this.options) === null || _a === void 0 ? void 0 : _a.preProcessors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
39
|
-
const labels = this.options.preProcessors.map((p) => string_ratchet_1.StringRatchet.trimToNull(p.label()) || 'Unlabelled');
|
|
40
|
-
this.info('Preprocessors: %j', labels);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
changeRingBufferSize(newSize) {
|
|
44
|
-
this._ringBuffer = null;
|
|
45
|
-
if (newSize) {
|
|
46
|
-
this._ringBuffer = new logger_ring_buffer_1.LoggerRingBuffer(newSize);
|
|
47
|
-
this._options.ringBufferSize = newSize;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
updateTracePrefix(newValue) {
|
|
51
|
-
this._options.trace = newValue;
|
|
52
|
-
}
|
|
53
|
-
get options() {
|
|
54
|
-
return Object.assign({}, this._options);
|
|
55
|
-
}
|
|
56
|
-
set options(newOpts) {
|
|
57
|
-
this._options = Object.assign({}, newOpts);
|
|
58
|
-
if (this._options.ringBufferSize) {
|
|
59
|
-
this._ringBuffer = new logger_ring_buffer_1.LoggerRingBuffer(this._options.ringBufferSize);
|
|
60
|
-
}
|
|
61
|
-
switch (this._options.formatType) {
|
|
62
|
-
case log_message_format_type_1.LogMessageFormatType.None:
|
|
63
|
-
this._formatter = new none_log_message_formatter_1.NoneLogMessageFormatter();
|
|
64
|
-
break;
|
|
65
|
-
case log_message_format_type_1.LogMessageFormatType.StructuredJson:
|
|
66
|
-
this._formatter = new structured_json_log_message_formatter_1.StructuredJsonLogMessageFormatter();
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
this._formatter = new classic_single_line_log_message_formatter_1.ClassicSingleLineLogMessageFormatter();
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
this._level = this._options.initialLevel;
|
|
73
|
-
this._handlerFunctionMap = logger_util_1.LoggerUtil.handlerFunctionMap(this._options.outputFunction);
|
|
74
|
-
const oldId = this._loggerMeta ? this._loggerMeta.loggerInstanceId : null;
|
|
75
|
-
this._loggerMeta = {
|
|
76
|
-
options: this._options,
|
|
77
|
-
loggerInstanceName: this.loggerInstanceName,
|
|
78
|
-
loggerInstanceId: oldId || string_ratchet_1.StringRatchet.createRandomHexString(8),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
get level() {
|
|
82
|
-
return this._level;
|
|
83
|
-
}
|
|
84
|
-
set level(newLevel) {
|
|
85
|
-
if (!newLevel) {
|
|
86
|
-
throw new Error('Cannot set level to null/undefined');
|
|
87
|
-
}
|
|
88
|
-
this._level = newLevel;
|
|
89
|
-
}
|
|
90
|
-
consoleLogPassThru(level, ...input) {
|
|
91
|
-
if (logger_util_1.LoggerUtil.levelIsEnabled(level, this._level)) {
|
|
92
|
-
let passThruPrefix = this._options.trace || '';
|
|
93
|
-
passThruPrefix += '[' + level + '] ';
|
|
94
|
-
input.unshift(passThruPrefix);
|
|
95
|
-
const fn = this._handlerFunctionMap.get(level) || logger_util_1.LoggerUtil.defaultHandlerFunction;
|
|
96
|
-
fn(...input);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
createLogMessage(level, params, format, ...input) {
|
|
100
|
-
const rval = {
|
|
101
|
-
lvl: level,
|
|
102
|
-
timestamp: Date.now(),
|
|
103
|
-
messageSource: format,
|
|
104
|
-
subsVars: input,
|
|
105
|
-
params: params,
|
|
106
|
-
};
|
|
107
|
-
return rval;
|
|
108
|
-
}
|
|
109
|
-
formatMessage(msg) {
|
|
110
|
-
const rval = msg ? this._formatter.formatMessage(msg, this._loggerMeta) : null;
|
|
111
|
-
return rval;
|
|
112
|
-
}
|
|
113
|
-
formatMessages(msgs) {
|
|
114
|
-
const rval = (msgs || []).map((m) => this.formatMessage(m)).filter((m) => !!m);
|
|
115
|
-
return rval;
|
|
116
|
-
}
|
|
117
|
-
recordMessageBuilder(msgBuild) {
|
|
118
|
-
return this.recordMessage(msgBuild.toMessage());
|
|
119
|
-
}
|
|
120
|
-
recordMessage(inMsg) {
|
|
121
|
-
var _a;
|
|
122
|
-
let rval = null;
|
|
123
|
-
if (logger_util_1.LoggerUtil.levelIsEnabled(inMsg.lvl, this._level)) {
|
|
124
|
-
let msg = Object.assign({}, inMsg);
|
|
125
|
-
if ((_a = this._options.preProcessors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
126
|
-
for (let i = 0; i < this._options.preProcessors.length; i++) {
|
|
127
|
-
msg = this._options.preProcessors[i].process(msg);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
rval = this.formatMessage(msg);
|
|
131
|
-
if (rval) {
|
|
132
|
-
const fn = this._handlerFunctionMap.get(msg.lvl) || logger_util_1.LoggerUtil.defaultHandlerFunction;
|
|
133
|
-
fn(rval);
|
|
134
|
-
if (this._ringBuffer) {
|
|
135
|
-
this._ringBuffer.addToRingBuffer(msg);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
}
|
|
141
|
-
return rval;
|
|
142
|
-
}
|
|
143
|
-
error(format, ...input) {
|
|
144
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.error, {}, format, ...input);
|
|
145
|
-
return this.recordMessage(msg);
|
|
146
|
-
}
|
|
147
|
-
errorP(...input) {
|
|
148
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.error, ...input);
|
|
149
|
-
}
|
|
150
|
-
warn(format, ...input) {
|
|
151
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.warn, {}, format, ...input);
|
|
152
|
-
return this.recordMessage(msg);
|
|
153
|
-
}
|
|
154
|
-
warnP(...input) {
|
|
155
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.warn, ...input);
|
|
156
|
-
}
|
|
157
|
-
info(format, ...input) {
|
|
158
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.info, {}, format, ...input);
|
|
159
|
-
return this.recordMessage(msg);
|
|
160
|
-
}
|
|
161
|
-
infoP(...input) {
|
|
162
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.info, ...input);
|
|
163
|
-
}
|
|
164
|
-
verbose(format, ...input) {
|
|
165
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.verbose, {}, format, ...input);
|
|
166
|
-
return this.recordMessage(msg);
|
|
167
|
-
}
|
|
168
|
-
verboseP(...input) {
|
|
169
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.verbose, ...input);
|
|
170
|
-
}
|
|
171
|
-
debug(format, ...input) {
|
|
172
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.debug, {}, format, ...input);
|
|
173
|
-
return this.recordMessage(msg);
|
|
174
|
-
}
|
|
175
|
-
debugP(...input) {
|
|
176
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.debug, ...input);
|
|
177
|
-
}
|
|
178
|
-
silly(format, ...input) {
|
|
179
|
-
const msg = this.createLogMessage(logger_level_name_1.LoggerLevelName.silly, {}, format, ...input);
|
|
180
|
-
return this.recordMessage(msg);
|
|
181
|
-
}
|
|
182
|
-
sillyP(...input) {
|
|
183
|
-
this.consoleLogPassThru(logger_level_name_1.LoggerLevelName.silly, ...input);
|
|
184
|
-
}
|
|
185
|
-
logByLevel(level, format, ...input) {
|
|
186
|
-
const msg = this.createLogMessage(level, {}, format, ...input);
|
|
187
|
-
this.recordMessage(msg);
|
|
188
|
-
}
|
|
189
|
-
importMessages(msgs, prefixIn = '', addTimestamp = true) {
|
|
190
|
-
const prefix = prefixIn || '';
|
|
191
|
-
if (msgs && msgs.length > 0) {
|
|
192
|
-
this.silly('Received import data : %d msgs', msgs.length);
|
|
193
|
-
msgs.forEach((m) => {
|
|
194
|
-
if (m.messageSource) {
|
|
195
|
-
let mOut = prefix;
|
|
196
|
-
if (addTimestamp) {
|
|
197
|
-
const ts = String(new Date()).substring(15, 24);
|
|
198
|
-
mOut += ' (' + ts + ') : ';
|
|
199
|
-
mOut += m.messageSource;
|
|
200
|
-
}
|
|
201
|
-
this.logByLevel(m.lvl, mOut);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.LoggerInstance = LoggerInstance;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerLevelName = void 0;
|
|
4
|
-
var LoggerLevelName;
|
|
5
|
-
(function (LoggerLevelName) {
|
|
6
|
-
LoggerLevelName["error"] = "error";
|
|
7
|
-
LoggerLevelName["warn"] = "warn";
|
|
8
|
-
LoggerLevelName["info"] = "info";
|
|
9
|
-
LoggerLevelName["verbose"] = "verbose";
|
|
10
|
-
LoggerLevelName["debug"] = "debug";
|
|
11
|
-
LoggerLevelName["silly"] = "silly";
|
|
12
|
-
})(LoggerLevelName = exports.LoggerLevelName || (exports.LoggerLevelName = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerOutputFunction = void 0;
|
|
4
|
-
var LoggerOutputFunction;
|
|
5
|
-
(function (LoggerOutputFunction) {
|
|
6
|
-
LoggerOutputFunction["Console"] = "Console";
|
|
7
|
-
LoggerOutputFunction["ConsoleNoDebug"] = "ConsoleNoDebug";
|
|
8
|
-
LoggerOutputFunction["StdOut"] = "StdOut";
|
|
9
|
-
})(LoggerOutputFunction = exports.LoggerOutputFunction || (exports.LoggerOutputFunction = {}));
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerRingBuffer = void 0;
|
|
4
|
-
const logger_1 = require("./logger");
|
|
5
|
-
const logger_level_name_1 = require("./logger-level-name");
|
|
6
|
-
class LoggerRingBuffer {
|
|
7
|
-
constructor(size) {
|
|
8
|
-
this._lastLogMessage = { messageSource: 'No message yet', timestamp: new Date().getTime(), lvl: logger_level_name_1.LoggerLevelName.info };
|
|
9
|
-
this._buffer = [];
|
|
10
|
-
this._bufferIdx = 0;
|
|
11
|
-
this._lastSnapshotIdx = 0;
|
|
12
|
-
if (!size) {
|
|
13
|
-
throw new Error('Cannot create ring buffer of size 0');
|
|
14
|
-
}
|
|
15
|
-
this._bufferSize = size;
|
|
16
|
-
}
|
|
17
|
-
get currentIndex() {
|
|
18
|
-
return this._bufferIdx;
|
|
19
|
-
}
|
|
20
|
-
get lastSnapshotIdx() {
|
|
21
|
-
return this._lastSnapshotIdx;
|
|
22
|
-
}
|
|
23
|
-
set bufferSize(newSize) {
|
|
24
|
-
if (!newSize) {
|
|
25
|
-
throw new Error('Cannot create ring buffer of size 0');
|
|
26
|
-
}
|
|
27
|
-
this._bufferSize = newSize;
|
|
28
|
-
this.clearRingBuffer();
|
|
29
|
-
}
|
|
30
|
-
getMessages(inStartFrom = null, clear = false, reverseSort = false) {
|
|
31
|
-
let rval = null;
|
|
32
|
-
if (this._bufferIdx < this._bufferSize) {
|
|
33
|
-
const start = inStartFrom == null ? 0 : inStartFrom;
|
|
34
|
-
rval = this._buffer.slice(start, this._bufferIdx);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
rval = [];
|
|
38
|
-
const firstIdx = this._bufferIdx - this._bufferSize;
|
|
39
|
-
const startFrom = inStartFrom ? Math.max(inStartFrom, firstIdx) : firstIdx;
|
|
40
|
-
for (let i = startFrom; i < this._bufferIdx; i++) {
|
|
41
|
-
rval.push(this._buffer[i % this._bufferSize]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (clear) {
|
|
45
|
-
this.clearRingBuffer();
|
|
46
|
-
}
|
|
47
|
-
if (reverseSort) {
|
|
48
|
-
rval = rval.reverse();
|
|
49
|
-
}
|
|
50
|
-
return rval;
|
|
51
|
-
}
|
|
52
|
-
takeSnapshot() {
|
|
53
|
-
const trailingEdge = Math.max(0, this._bufferIdx - this._bufferSize);
|
|
54
|
-
const rval = {
|
|
55
|
-
messages: logger_1.Logger.getMessages(this._lastSnapshotIdx),
|
|
56
|
-
logMessagesTruncated: Math.max(0, trailingEdge - this._lastSnapshotIdx),
|
|
57
|
-
};
|
|
58
|
-
this._lastSnapshotIdx = this._bufferIdx;
|
|
59
|
-
return rval;
|
|
60
|
-
}
|
|
61
|
-
getLastLogMessage() {
|
|
62
|
-
return Object.assign({}, this._lastLogMessage);
|
|
63
|
-
}
|
|
64
|
-
clearRingBuffer() {
|
|
65
|
-
this._buffer = [];
|
|
66
|
-
this._bufferIdx = 0;
|
|
67
|
-
this._lastSnapshotIdx = 0;
|
|
68
|
-
logger_1.Logger.info('Cleared ring buffer (size is now %d)', this._bufferSize);
|
|
69
|
-
}
|
|
70
|
-
addToRingBuffer(newMsg) {
|
|
71
|
-
this._lastLogMessage = newMsg;
|
|
72
|
-
this._buffer[this._bufferIdx % this._bufferSize] = newMsg;
|
|
73
|
-
this._bufferIdx++;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.LoggerRingBuffer = LoggerRingBuffer;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerUtil = void 0;
|
|
4
|
-
const logger_level_name_1 = require("./logger-level-name");
|
|
5
|
-
const logger_output_function_1 = require("./logger-output-function");
|
|
6
|
-
class LoggerUtil {
|
|
7
|
-
static handlerFunctionMap(outputFn = logger_output_function_1.LoggerOutputFunction.Console) {
|
|
8
|
-
var _a;
|
|
9
|
-
const output = new Map();
|
|
10
|
-
if (outputFn === logger_output_function_1.LoggerOutputFunction.StdOut) {
|
|
11
|
-
if (!((_a = process === null || process === void 0 ? void 0 : process.stdout) === null || _a === void 0 ? void 0 : _a.write)) {
|
|
12
|
-
throw new Error('Cannot use standard out - process.stdout.write not found');
|
|
13
|
-
}
|
|
14
|
-
const myStdOut = (chunk, cb) => process.stdout.write(chunk, 'utf-8', cb);
|
|
15
|
-
output.set(logger_level_name_1.LoggerLevelName.error, myStdOut);
|
|
16
|
-
output.set(logger_level_name_1.LoggerLevelName.warn, myStdOut);
|
|
17
|
-
output.set(logger_level_name_1.LoggerLevelName.info, myStdOut);
|
|
18
|
-
output.set(logger_level_name_1.LoggerLevelName.verbose, myStdOut);
|
|
19
|
-
output.set(logger_level_name_1.LoggerLevelName.debug, myStdOut);
|
|
20
|
-
output.set(logger_level_name_1.LoggerLevelName.silly, myStdOut);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
output.set(logger_level_name_1.LoggerLevelName.error, console.error);
|
|
24
|
-
output.set(logger_level_name_1.LoggerLevelName.warn, console.warn);
|
|
25
|
-
output.set(logger_level_name_1.LoggerLevelName.info, console.info);
|
|
26
|
-
output.set(logger_level_name_1.LoggerLevelName.verbose, outputFn === logger_output_function_1.LoggerOutputFunction.ConsoleNoDebug ? console.log : console.debug);
|
|
27
|
-
output.set(logger_level_name_1.LoggerLevelName.debug, outputFn === logger_output_function_1.LoggerOutputFunction.ConsoleNoDebug ? console.log : console.debug);
|
|
28
|
-
output.set(logger_level_name_1.LoggerLevelName.silly, outputFn === logger_output_function_1.LoggerOutputFunction.ConsoleNoDebug ? console.log : console.debug);
|
|
29
|
-
}
|
|
30
|
-
return output;
|
|
31
|
-
}
|
|
32
|
-
static defaultHandlerFunction() {
|
|
33
|
-
return console.info;
|
|
34
|
-
}
|
|
35
|
-
static levelIsEnabled(targetLevel, currentEnabled) {
|
|
36
|
-
const idxTarget = LoggerUtil.LOG_LEVELS_IN_ORDER.indexOf(targetLevel);
|
|
37
|
-
const lvl = LoggerUtil.LOG_LEVELS_IN_ORDER.indexOf(currentEnabled);
|
|
38
|
-
return idxTarget > -1 && lvl > -1 && lvl >= idxTarget;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.LoggerUtil = LoggerUtil;
|
|
42
|
-
LoggerUtil.LOG_LEVELS_IN_ORDER = [
|
|
43
|
-
logger_level_name_1.LoggerLevelName.error,
|
|
44
|
-
logger_level_name_1.LoggerLevelName.warn,
|
|
45
|
-
logger_level_name_1.LoggerLevelName.info,
|
|
46
|
-
logger_level_name_1.LoggerLevelName.verbose,
|
|
47
|
-
logger_level_name_1.LoggerLevelName.debug,
|
|
48
|
-
logger_level_name_1.LoggerLevelName.silly,
|
|
49
|
-
];
|