modality-kit 0.11.0 → 0.11.1
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/index.js +9 -3
- package/dist/types/util_logger.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,7 +77,7 @@ function formatErrorResponse(errorData, operation, meta) {
|
|
|
77
77
|
return JSON.stringify(errorResponse);
|
|
78
78
|
}
|
|
79
79
|
// src/util_logger.ts
|
|
80
|
-
var levels = ["debug", "info", "warn", "error", "success"];
|
|
80
|
+
var levels = [null, "debug", "info", "warn", "error", "success"];
|
|
81
81
|
|
|
82
82
|
class ModalityLogger {
|
|
83
83
|
options = {};
|
|
@@ -88,8 +88,7 @@ class ModalityLogger {
|
|
|
88
88
|
} else {
|
|
89
89
|
this.options = { ...this.options, ...logOption };
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
this.logLevel = logLevel || (levels.indexOf(processEnvLogLevel) !== -1 ? processEnvLogLevel : "info");
|
|
91
|
+
this.logLevel = logLevel || null;
|
|
93
92
|
}
|
|
94
93
|
static getInstance(logOption, logLevel) {
|
|
95
94
|
return new ModalityLogger(logOption, logLevel);
|
|
@@ -102,7 +101,14 @@ class ModalityLogger {
|
|
|
102
101
|
return now.toLocaleString();
|
|
103
102
|
return now.toISOString();
|
|
104
103
|
}
|
|
104
|
+
initLogLevel() {
|
|
105
|
+
const processEnvLogLevel = process.env.MODALITY_LOG_LEVEL;
|
|
106
|
+
this.logLevel = levels.indexOf(processEnvLogLevel) !== -1 ? processEnvLogLevel : "info";
|
|
107
|
+
}
|
|
105
108
|
shouldLog(level) {
|
|
109
|
+
if (!this.logLevel) {
|
|
110
|
+
this.initLogLevel();
|
|
111
|
+
}
|
|
106
112
|
return levels.indexOf(level) >= levels.indexOf(this.logLevel);
|
|
107
113
|
}
|
|
108
114
|
setLogLevel(level) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Storage Logger for structured logging
|
|
3
3
|
* Provides consistent logging across storage operations with configurable levels
|
|
4
4
|
*/
|
|
5
|
-
declare const levels: readonly ["debug", "info", "warn", "error", "success"];
|
|
5
|
+
declare const levels: readonly [null, "debug", "info", "warn", "error", "success"];
|
|
6
6
|
export type LogLevel = (typeof levels)[number];
|
|
7
7
|
export interface LoggerOptions {
|
|
8
8
|
timestampFormat?: "iso" | "locale" | false;
|
|
@@ -14,6 +14,7 @@ export declare class ModalityLogger {
|
|
|
14
14
|
private constructor();
|
|
15
15
|
static getInstance(logOption: string | LoggerOptions, logLevel?: LogLevel): ModalityLogger;
|
|
16
16
|
private getTimestamp;
|
|
17
|
+
private initLogLevel;
|
|
17
18
|
private shouldLog;
|
|
18
19
|
setLogLevel(level: LogLevel): void;
|
|
19
20
|
private format;
|
package/package.json
CHANGED