@tachybase/logger 1.3.52 → 1.3.53

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/lib/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const getLoggerLevel: () => string;
1
+ export declare const getLoggerLevel: () => any;
2
2
  export declare const getLoggerFilePath: (...paths: string[]) => string;
3
3
  export declare const getLoggerTransport: () => ("console" | "file" | "dailyRotateFile")[];
4
4
  export declare const getLoggerFormat: () => "logfmt" | "json" | "delimiter" | "console";
package/lib/config.js CHANGED
@@ -35,15 +35,16 @@ __export(config_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(config_exports);
37
37
  var import_node_path = __toESM(require("node:path"));
38
- const getLoggerLevel = /* @__PURE__ */ __name(() => process.env.LOGGER_LEVEL || (process.env.APP_ENV === "development" ? "debug" : "info"), "getLoggerLevel");
38
+ var import_globals = __toESM(require("@tachybase/globals"));
39
+ const getLoggerLevel = /* @__PURE__ */ __name(() => import_globals.default.settings.logger.level ?? "info", "getLoggerLevel");
39
40
  const getLoggerFilePath = /* @__PURE__ */ __name((...paths) => {
40
41
  return import_node_path.default.resolve(
41
- import_node_path.default.resolve(process.env.TEGO_RUNTIME_HOME, process.env.LOGGER_BASE_PATH ?? "storage/logs"),
42
+ import_node_path.default.resolve(process.env.TEGO_RUNTIME_HOME, import_globals.default.settings.logger.basePath ?? "storage/logs"),
42
43
  ...paths
43
44
  );
44
45
  }, "getLoggerFilePath");
45
- const getLoggerTransport = /* @__PURE__ */ __name(() => (process.env.LOGGER_TRANSPORT || "console,dailyRotateFile").split(","), "getLoggerTransport");
46
- const getLoggerFormat = /* @__PURE__ */ __name(() => process.env.LOGGER_FORMAT || (process.env.APP_ENV === "development" ? "console" : "json"), "getLoggerFormat");
46
+ const getLoggerTransport = /* @__PURE__ */ __name(() => import_globals.default.settings.logger.transport ?? ["console", "dailyRotateFile"], "getLoggerTransport");
47
+ const getLoggerFormat = /* @__PURE__ */ __name(() => import_globals.default.settings.logger.format ?? "console", "getLoggerFormat");
47
48
  // Annotate the CommonJS export names for ESM import in node:
48
49
  0 && (module.exports = {
49
50
  getLoggerFilePath,
@@ -44,8 +44,8 @@ const requestLogger = /* @__PURE__ */ __name((appName, options) => {
44
44
  var _a, _b, _c, _d, _e, _f, _g, _h;
45
45
  const reqId = ctx.reqId;
46
46
  const path = /^\/api\/(.+):(.+)/.exec(ctx.path);
47
- const contextLogger = ctx.app.log.child({ reqId, module: path == null ? void 0 : path[1], submodule: path == null ? void 0 : path[2] });
48
- ctx.logger = ctx.log = contextLogger;
47
+ const contextLogger = ctx.tego.log.child({ reqId, module: path == null ? void 0 : path[1], submodule: path == null ? void 0 : path[2] });
48
+ ctx.logger = contextLogger;
49
49
  const startTime = Date.now();
50
50
  const requestInfo = {
51
51
  method: ctx.method,
package/lib/transports.js CHANGED
@@ -33,19 +33,20 @@ __export(transports_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(transports_exports);
35
35
  var import_node_path = __toESM(require("node:path"));
36
+ var import_globals = __toESM(require("@tachybase/globals"));
36
37
  var import_winston = __toESM(require("winston"));
37
38
  var import_config = require("./config");
38
39
  var import_format = require("./format");
39
40
  const Transports = {
40
41
  console: /* @__PURE__ */ __name((options) => new import_winston.default.transports.Console(options), "console"),
41
42
  file: /* @__PURE__ */ __name((options) => new import_winston.default.transports.File({
42
- maxsize: Number(process.env.LOGGER_MAX_SIZE) || 1024 * 1024 * 20,
43
- maxFiles: Number(process.env.LOGGER_MAX_FILES) || 10,
43
+ maxsize: Number(import_globals.default.settings.logger.maxSize ?? 1024 * 1024 * 20),
44
+ maxFiles: Number(import_globals.default.settings.logger.maxFiles ?? 10),
44
45
  ...options
45
46
  }), "file"),
46
47
  dailyRotateFile: /* @__PURE__ */ __name((options) => new import_winston.default.transports.DailyRotateFile({
47
- maxSize: Number(process.env.LOGGER_MAX_SIZE),
48
- maxFiles: Number(process.env.LOGGER_MAX_FILES) || "14d",
48
+ maxSize: import_globals.default.settings.logger.maxSize,
49
+ maxFiles: import_globals.default.settings.logger.maxFiles ?? "14d",
49
50
  ...options
50
51
  }), "dailyRotateFile")
51
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/logger",
3
- "version": "1.3.52",
3
+ "version": "1.3.53",
4
4
  "description": "logging library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
@@ -11,6 +11,7 @@
11
11
  "triple-beam": "^1.4.1",
12
12
  "winston": "^3.17.0",
13
13
  "winston-daily-rotate-file": "^5.0.0",
14
- "winston-transport": "^4.9.0"
14
+ "winston-transport": "^4.9.0",
15
+ "@tachybase/globals": "1.3.53"
15
16
  }
16
17
  }