@bonginkan/maria 4.3.9 → 4.3.12

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
@@ -14689,32 +14689,48 @@ var Logger = class {
14689
14689
  level = 2 /* WARN */;
14690
14690
  // Default to WARN to reduce noise
14691
14691
  prefix = "[MARIA CODE]";
14692
+ format = "pretty";
14692
14693
  setLevel(level) {
14693
14694
  this.level = level;
14694
14695
  }
14696
+ setFormat(format) {
14697
+ this.format = format;
14698
+ }
14699
+ out(level, tag, args) {
14700
+ if (this.format === "json") {
14701
+ const payload = {
14702
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
14703
+ level: tag.replace(/\[|\]/g, "").toLowerCase(),
14704
+ msg: args.map(String).join(" ")
14705
+ };
14706
+ console[level](JSON.stringify(payload));
14707
+ return;
14708
+ }
14709
+ console[level](tag, ...args);
14710
+ }
14695
14711
  debug(...args) {
14696
14712
  if (this.level <= 0 /* DEBUG */) {
14697
- console.log(chalk3.magenta(`${this.prefix} [DEBUG]`), ...args);
14713
+ this.out("log", chalk3.magenta(`${this.prefix} [DEBUG]`), args);
14698
14714
  }
14699
14715
  }
14700
14716
  info(...args) {
14701
14717
  if (this.level <= 1 /* INFO */) {
14702
- console.log(chalk3.bold.magenta(`${this.prefix} [INFO]`), ...args);
14718
+ this.out("log", chalk3.bold.magenta(`${this.prefix} [INFO]`), args);
14703
14719
  }
14704
14720
  }
14705
14721
  warn(...args) {
14706
14722
  if (this.level <= 2 /* WARN */) {
14707
- console.warn(chalk3.bold.magenta(`${this.prefix} [WARN]`), ...args);
14723
+ this.out("warn", chalk3.bold.magenta(`${this.prefix} [WARN]`), args);
14708
14724
  }
14709
14725
  }
14710
14726
  error(...args) {
14711
14727
  if (this.level <= 3 /* ERROR */) {
14712
- console.error(chalk3.bold.magenta(`${this.prefix} [ERROR]`), ...args);
14728
+ this.out("error", chalk3.bold.magenta(`${this.prefix} [ERROR]`), args);
14713
14729
  }
14714
14730
  }
14715
14731
  success(...args) {
14716
14732
  if (this.level <= 1 /* INFO */) {
14717
- console.log(chalk3.bold.magenta(`${this.prefix} [SUCCESS]`), ...args);
14733
+ this.out("log", chalk3.bold.magenta(`${this.prefix} [SUCCESS]`), args);
14718
14734
  }
14719
14735
  }
14720
14736
  task(taskName, status, message) {
@@ -14748,8 +14764,12 @@ var Logger = class {
14748
14764
  if (this.level > 0 /* DEBUG */) {
14749
14765
  return;
14750
14766
  }
14751
- console.log(chalk3.magenta(`${this.prefix} [JSON]`));
14752
- console.log(pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj));
14767
+ if (this.format === "json") {
14768
+ this.out("log", "", [JSON.stringify(obj)]);
14769
+ } else {
14770
+ console.log(chalk3.magenta(`${this.prefix} [JSON]`));
14771
+ console.log(pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj));
14772
+ }
14753
14773
  }
14754
14774
  divider() {
14755
14775
  if (this.level > 1 /* INFO */) {
@@ -14787,6 +14807,10 @@ var envLogLevel = process.env["MARIA_LOG_LEVEL"]?.toUpperCase();
14787
14807
  if (envLogLevel && LogLevel[envLogLevel] !== void 0) {
14788
14808
  logger.setLevel(LogLevel[envLogLevel]);
14789
14809
  }
14810
+ var envLogFormat = process.env["MARIA_LOG_FORMAT"]?.toLowerCase();
14811
+ if (envLogFormat === "json" || envLogFormat === "pretty") {
14812
+ logger.setFormat(envLogFormat);
14813
+ }
14790
14814
  var FeatureFlagController = class {
14791
14815
  config;
14792
14816
  status;