@edirect/logger 11.0.58 → 11.0.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/logger",
3
- "version": "11.0.57",
3
+ "version": "11.0.59",
4
4
  "main": "./dist/src/index.js",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@edirect/config": "^11.0.57",
19
+ "@edirect/config": "^11.0.59",
20
20
  "@nestjs/common": "^11.1.19",
21
21
  "pino": "10.3.1",
22
22
  "supertest": "7.2.2",
@@ -1,4 +1,5 @@
1
1
  export * from './context/async-context';
2
+ export * from './logger/interfaces/logger-module-options.interface';
2
3
  export * from './logger/logger.class';
3
4
  export * from './logger/logger.module';
4
5
  export * from './logger/logger.service';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qDAAqD,CAAC;AACpE,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC"}
package/dist/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./context/async-context"), exports);
5
+ tslib_1.__exportStar(require("./logger/interfaces/logger-module-options.interface"), exports);
5
6
  tslib_1.__exportStar(require("./logger/logger.class"), exports);
6
7
  tslib_1.__exportStar(require("./logger/logger.module"), exports);
7
8
  tslib_1.__exportStar(require("./logger/logger.service"), exports);
@@ -1,19 +1,14 @@
1
- import { Level } from 'pino';
1
+ import { Level, LoggerOptions } from 'pino';
2
2
  export interface LoggerModuleOptions {
3
- output?: 'console' | 'file' | 'both';
4
- logs?: {
5
- errorFile: string;
6
- warningFile: string;
7
- infoFile: string;
8
- exceptionsFile?: string;
9
- minLength?: number;
10
- sync?: boolean;
11
- };
3
+ output?: 'console';
12
4
  name?: string;
13
5
  host?: string;
14
6
  protocol?: string;
15
7
  version?: string;
16
8
  level?: Level;
17
9
  payloadFieldName?: 'details' | 'payload';
10
+ mixin?: () => Record<string, unknown>;
11
+ baseExtension?: Record<string, unknown>;
12
+ pinoOptions?: Omit<LoggerOptions, 'level' | 'timestamp' | 'messageKey' | 'errorKey' | 'formatters' | 'base' | 'mixin'>;
18
13
  }
19
14
  //# sourceMappingURL=logger-module-options.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger-module-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/logger/interfaces/logger-module-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IACrC,IAAI,CAAC,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gBAAgB,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC1C"}
1
+ {"version":3,"file":"logger-module-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/logger/interfaces/logger-module-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gBAAgB,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,IAAI,CAChB,aAAa,EACb,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CACpF,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/logger/log.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnF,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,M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AG,IAAI;IAIlE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;IACpE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;IAClE,KAAK,CACH,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,KAAK,CAAC,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI;IA+CP,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;IAIrE,UAAU,CAAC,GAAG,EAAE,MAAM,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzD,OAAO,CAAC,QAAQ;CAmCjB"}
@@ -2,21 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Logger = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const pino_1 = tslib_1.__importStar(require("pino"));
5
+ const pino_1 = tslib_1.__importDefault(require("pino"));
6
6
  const async_context_1 = require("../context/async-context");
7
7
  class Logger {
8
8
  configs;
9
9
  logger;
10
10
  constructor(env, options) {
11
11
  const defaults = {
12
- logs: {
13
- infoFile: env.LOGS_INFO_FILE,
14
- warningFile: env.LOGS_WARNING_FILE,
15
- errorFile: env.LOGS_ERROR_FILE,
16
- exceptionsFile: env.LOGS_EXCEPTIONS_FILE,
17
- },
18
12
  level: env.LOGS_LEVEL?.toLowerCase() || 'info',
19
- output: env.LOGS_OUTPUT ?? 'console',
20
13
  name: env.npm_package_name ?? env.APP_NAME ?? 'app',
21
14
  version: env.npm_package_version ?? env.APP_VERSION ?? '0.0.0',
22
15
  host: env.LOGS_HOST ?? '0.0.0.0',
@@ -25,49 +18,8 @@ class Logger {
25
18
  'payload',
26
19
  };
27
20
  this.configs = { ...defaults, ...options };
28
- const streams = [];
29
- if (this.configs.output === 'file' || this.configs.output === 'both') {
30
- if (this.configs.logs?.infoFile) {
31
- streams.push({
32
- level: 'info',
33
- stream: pino_1.default.destination({
34
- dest: this.configs.logs.infoFile,
35
- mkdir: true,
36
- sync: this.configs.logs.sync ?? false,
37
- minLength: this.configs.logs.minLength ?? 4096,
38
- }),
39
- });
40
- }
41
- if (this.configs.logs?.warningFile) {
42
- streams.push({
43
- level: 'warn',
44
- stream: pino_1.default.destination({
45
- dest: this.configs.logs.warningFile,
46
- mkdir: true,
47
- sync: this.configs.logs.sync ?? false,
48
- minLength: this.configs.logs.minLength ?? 4096,
49
- }),
50
- });
51
- }
52
- if (this.configs.logs?.errorFile) {
53
- streams.push({
54
- level: 'error',
55
- stream: pino_1.default.destination({
56
- dest: this.configs.logs.errorFile,
57
- mkdir: true,
58
- sync: this.configs.logs.sync ?? false,
59
- minLength: this.configs.logs.minLength ?? 4096,
60
- }),
61
- });
62
- }
63
- }
64
- if (this.configs.output === 'console' || this.configs.output === 'both') {
65
- streams.push({
66
- level: this.configs.level,
67
- stream: process.stdout,
68
- });
69
- }
70
21
  this.logger = (0, pino_1.default)({
22
+ ...(this.configs.pinoOptions ?? {}),
71
23
  level: this.configs.level,
72
24
  timestamp: () => `,"timestamp":"${new Date().toISOString()}"`,
73
25
  messageKey: 'message',
@@ -77,31 +29,13 @@ class Logger {
77
29
  version: this.configs.version,
78
30
  host: this.configs.host,
79
31
  protocol: this.configs.protocol,
32
+ ...this.configs.baseExtension,
80
33
  },
81
34
  formatters: {
82
35
  level: label => ({ level: label }),
83
36
  },
84
- }, (0, pino_1.multistream)(streams));
85
- if (this.configs.logs?.exceptionsFile) {
86
- const exceptionLogger = (0, pino_1.default)({
87
- level: 'fatal',
88
- timestamp: () => `,"timestamp":"${new Date().toISOString()}"`,
89
- messageKey: 'message',
90
- errorKey: 'error',
91
- }, pino_1.default.destination({
92
- dest: this.configs.logs.exceptionsFile,
93
- mkdir: true,
94
- sync: true,
95
- }));
96
- process.on('uncaughtException', err => {
97
- exceptionLogger.fatal({ err }, 'Uncaught exception');
98
- process.exit(1);
99
- });
100
- process.on('unhandledRejection', reason => {
101
- exceptionLogger.fatal({ reason }, 'Unhandled rejection');
102
- process.exit(1);
103
- });
104
- }
37
+ ...(this.configs.mixin ? { mixin: this.configs.mixin } : {}),
38
+ });
105
39
  }
106
40
  debug(message, payload, remoteAddress) {
107
41
  this.logger.debug(this.buildLog(payload, remoteAddress), message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/logger",
3
- "version": "11.0.58",
3
+ "version": "11.0.59",
4
4
  "packageScope": "@edirect",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "pino": "10.3.1",
22
22
  "supertest": "7.2.2",
23
23
  "tslib": "^2.8.1",
24
- "@edirect/config": "11.0.58"
24
+ "@edirect/config": "11.0.59"
25
25
  },
26
26
  "nx": {
27
27
  "name": "@edirect/logger",