modality-kit 0.10.3 → 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 CHANGED
@@ -77,18 +77,18 @@ 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 = {};
84
- logLevel = "info";
85
- constructor(logOption, logLevel = "info") {
84
+ logLevel;
85
+ constructor(logOption, logLevel) {
86
86
  if (typeof logOption === "string") {
87
87
  this.options.name = logOption;
88
88
  } else {
89
89
  this.options = { ...this.options, ...logOption };
90
90
  }
91
- this.logLevel = logLevel;
91
+ this.logLevel = logLevel || null;
92
92
  }
93
93
  static getInstance(logOption, logLevel) {
94
94
  return new ModalityLogger(logOption, logLevel);
@@ -101,7 +101,14 @@ class ModalityLogger {
101
101
  return now.toLocaleString();
102
102
  return now.toISOString();
103
103
  }
104
+ initLogLevel() {
105
+ const processEnvLogLevel = process.env.MODALITY_LOG_LEVEL;
106
+ this.logLevel = levels.indexOf(processEnvLogLevel) !== -1 ? processEnvLogLevel : "info";
107
+ }
104
108
  shouldLog(level) {
109
+ if (!this.logLevel) {
110
+ this.initLogLevel();
111
+ }
105
112
  return levels.indexOf(level) >= levels.indexOf(this.logLevel);
106
113
  }
107
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.10.3",
2
+ "version": "0.11.1",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",