@athenna/logger 4.2.0 → 4.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/logger",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "The Athenna logging solution. Log in stdout, files and buckets.",
5
5
  "license": "MIT",
6
6
  "author": "João Lenon <lenon@athenna.io>",
@@ -40,9 +40,9 @@
40
40
  "types": "./src/index.d.ts",
41
41
  "exports": {
42
42
  ".": "./src/index.js",
43
- "./providers/LoggerProvider": "./src/providers/LoggerProvider.js",
44
43
  "./types": "./src/types/index.js",
45
- "./package.json": "./package.json"
44
+ "./package.json": "./package.json",
45
+ "./providers/LoggerProvider": "./src/providers/LoggerProvider.js"
46
46
  },
47
47
  "imports": {
48
48
  "#bin/*": "./bin/*.js",
@@ -59,10 +59,10 @@
59
59
  "cls-rtracer": "^2.6.3"
60
60
  },
61
61
  "devDependencies": {
62
- "@athenna/common": "^4.4.0",
63
- "@athenna/config": "^4.3.0",
64
- "@athenna/ioc": "^4.1.0",
65
- "@athenna/test": "^4.3.0",
62
+ "@athenna/common": "^4.10.1",
63
+ "@athenna/config": "^4.4.0",
64
+ "@athenna/ioc": "^4.2.0",
65
+ "@athenna/test": "^4.5.0",
66
66
  "@typescript-eslint/eslint-plugin": "^5.56.0",
67
67
  "@typescript-eslint/parser": "^5.56.0",
68
68
  "c8": "^7.12.0",
@@ -119,7 +119,7 @@
119
119
  },
120
120
  "prettier": {
121
121
  "singleQuote": true,
122
- "trailingComma": "all",
122
+ "trailingComma": "none",
123
123
  "arrowParens": "avoid",
124
124
  "endOfLine": "lf",
125
125
  "semi": false,
@@ -14,41 +14,41 @@
14
14
  export const VANILLA_CHANNELS = {
15
15
  default: {
16
16
  driver: 'stack',
17
- channels: ['application'],
17
+ channels: ['application']
18
18
  },
19
19
  stack: {
20
20
  driver: 'stack',
21
- channels: ['application'],
21
+ channels: ['application']
22
22
  },
23
23
  discard: {
24
- driver: 'null',
24
+ driver: 'null'
25
25
  },
26
26
  file: {
27
27
  driver: 'file',
28
28
  level: 'trace',
29
29
  filePath: Path.logs('athenna.log'),
30
30
  formatter: 'simple',
31
- formatterConfig: {},
31
+ formatterConfig: {}
32
32
  },
33
33
  console: {
34
34
  level: 'trace',
35
35
  formatter: 'cli',
36
- driver: 'console',
36
+ driver: 'console'
37
37
  },
38
38
  request: {
39
39
  level: 'trace',
40
40
  formatter: 'request',
41
- driver: 'console',
41
+ driver: 'console'
42
42
  },
43
43
  exception: {
44
44
  level: 'trace',
45
45
  formatter: 'none',
46
46
  driver: 'console',
47
- streamType: 'stderr',
47
+ streamType: 'stderr'
48
48
  },
49
49
  application: {
50
50
  level: 'trace',
51
51
  driver: 'console',
52
- formatter: 'simple',
53
- },
52
+ formatter: 'simple'
53
+ }
54
54
  };
@@ -18,7 +18,7 @@ export class DiscordDriver extends Driver {
18
18
  debug('[%s] Transporting logs with username %s and in url %s.', DiscordDriver.name, this.configs.username, this.configs.url);
19
19
  return HttpClient.builder(true).post(this.configs.url, {
20
20
  username: this.configs.username,
21
- content: formatted,
21
+ content: formatted
22
22
  });
23
23
  }
24
24
  }
@@ -41,7 +41,7 @@ export class Driver {
41
41
  'success',
42
42
  'warn',
43
43
  'error',
44
- 'fatal',
44
+ 'fatal'
45
45
  ];
46
46
  this.configs = configs;
47
47
  const json = Json.copy(configs);
@@ -17,7 +17,7 @@ export class TelegramDriver extends Driver {
17
17
  const formatted = this.format(level, message, true);
18
18
  debug('[%s] Transporting logs with parse mode as %s, using %s token and %s chatId.', TelegramDriver.name, this.driverConfig.parseMode, this.driverConfig.token, this.driverConfig.chatId);
19
19
  return new Telegraf(this.driverConfig.token).telegram.sendMessage(this.driverConfig.chatId, formatted, {
20
- parse_mode: this.driverConfig.parseMode,
20
+ parse_mode: this.driverConfig.parseMode
21
21
  });
22
22
  }
23
23
  }
@@ -15,7 +15,7 @@ export class DriverExistException extends Exception {
15
15
  status: 500,
16
16
  code: 'E_EXIST_DRIVER',
17
17
  message: `The driver ${driverName} already exists in DriverFactory.`,
18
- help: `Available drivers are: ${availableDrivers}. The name ${driverName} is already in use inside DriverFactory. Try using a different name for your driver implementation.`,
18
+ help: `Available drivers are: ${availableDrivers}. The name ${driverName} is already in use inside DriverFactory. Try using a different name for your driver implementation.`
19
19
  });
20
20
  }
21
21
  }
@@ -15,7 +15,7 @@ export class FormatterExistException extends Exception {
15
15
  status: 500,
16
16
  code: 'E_EXIST_FORMATTER',
17
17
  message: `The formatter ${formatterName} already exists in FormatterFactory.`,
18
- help: `Available formatters are: ${availableFormatters}. The name ${formatterName} is already in use inside FormatterFactory. Try using a different name for your formatter implementation.`,
18
+ help: `Available formatters are: ${availableFormatters}. The name ${formatterName} is already in use inside FormatterFactory. Try using a different name for your formatter implementation.`
19
19
  });
20
20
  }
21
21
  }
@@ -15,7 +15,7 @@ export class NotFoundDriverException extends Exception {
15
15
  status: 500,
16
16
  code: 'E_NOT_FOUND',
17
17
  message: `The driver ${driverName} has not been found.`,
18
- help: `Available drivers are: ${availableDrivers}. Look into your config/logger.${Path.ext()} file if ${driverName} driver is implemented by logger. Or create ${driverName} driver implementation using DriverFactory.createDriver("${driverName}", ...) method.`,
18
+ help: `Available drivers are: ${availableDrivers}. Look into your config/logger.${Path.ext()} file if ${driverName} driver is implemented by logger. Or create ${driverName} driver implementation using DriverFactory.createDriver("${driverName}", ...) method.`
19
19
  });
20
20
  }
21
21
  }
@@ -15,7 +15,7 @@ export class NotFoundFormatterException extends Exception {
15
15
  status: 500,
16
16
  code: 'E_NOT_FOUND',
17
17
  message: `The formatter ${formatterName} has not been found.`,
18
- help: `Available formatters are: ${availableDrivers}. Look into your config/logger file if ${formatterName} formatter is implemented by logger. Or create ${formatterName} formatter implementation using FormatterFactory.createFormatter("${formatterName}", ...) method.`,
18
+ help: `Available formatters are: ${availableDrivers}. Look into your config/logger file if ${formatterName} formatter is implemented by logger. Or create ${formatterName} formatter implementation using FormatterFactory.createFormatter("${formatterName}", ...) method.`
19
19
  });
20
20
  }
21
21
  }
@@ -23,7 +23,7 @@ export class NotImplementedConfigException extends Exception {
23
23
  status: 500,
24
24
  code: 'E_NOT_IMPLEMENTED_CONFIG_ERROR',
25
25
  message: `Channel ${channelName} is not configured inside logging.channels object from config/logging.${Path.ext()} file.`,
26
- help,
26
+ help
27
27
  });
28
28
  }
29
29
  }
@@ -58,7 +58,7 @@ class DriverFactory {
58
58
  static fabricateVanilla(configs = {}) {
59
59
  configs = Options.create(configs, {
60
60
  driver: 'console',
61
- formatter: 'none',
61
+ formatter: 'none'
62
62
  });
63
63
  if (!this.drivers.has(configs.driver)) {
64
64
  throw new NotFoundDriverException(configs.driver);
@@ -57,7 +57,7 @@ export class Formatter {
57
57
  minute: 'numeric',
58
58
  second: 'numeric',
59
59
  day: '2-digit',
60
- month: '2-digit',
60
+ month: '2-digit'
61
61
  };
62
62
  return new Date(Date.now()).toLocaleString(undefined, localeStringOptions);
63
63
  }
@@ -149,7 +149,7 @@ export class Formatter {
149
149
  success: '\u{2705}',
150
150
  warn: '\u{26A0}',
151
151
  error: '\u{274C}',
152
- fatal: '\u{1F6D1}',
152
+ fatal: '\u{1F6D1}'
153
153
  };
154
154
  if (!levelEmojis[level.toLowerCase()]) {
155
155
  return '';
@@ -168,7 +168,7 @@ export class Formatter {
168
168
  success: Color.success,
169
169
  warn: Color.warn,
170
170
  error: Color.error,
171
- fatal: Color.fatal,
171
+ fatal: Color.fatal
172
172
  };
173
173
  if (!levelColors[levelLower]) {
174
174
  return message;
@@ -15,7 +15,7 @@ export class JsonFormatter extends Formatter {
15
15
  time: Date.now(),
16
16
  pid: this.pid(),
17
17
  hostname: this.hostname(),
18
- traceId: this.traceId(),
18
+ traceId: this.traceId()
19
19
  };
20
20
  if (Is.String(message)) {
21
21
  base.msg = message;
@@ -29,7 +29,7 @@ export class RequestFormatter extends Formatter {
29
29
  path: ctx.request.baseUrl,
30
30
  createdAt: Date.now(),
31
31
  traceId: this.traceId(),
32
- data: ctx.data,
32
+ data: ctx.data
33
33
  };
34
34
  const request = {
35
35
  url: ctx.request.hostUrl,
@@ -37,11 +37,11 @@ export class RequestFormatter extends Formatter {
37
37
  body: ctx.request.body,
38
38
  params: ctx.request.params,
39
39
  queries: ctx.request.queries,
40
- headers: ctx.request.headers,
40
+ headers: ctx.request.headers
41
41
  };
42
42
  const response = {
43
43
  body: ctx.body,
44
- headers: ctx.headers,
44
+ headers: ctx.headers
45
45
  };
46
46
  return JSON.stringify({ request, response, metadata });
47
47
  }
@@ -77,7 +77,7 @@ export class Logger {
77
77
  }
78
78
  return this.vanilla({
79
79
  ...VANILLA_CHANNELS[channel],
80
- ...configs,
80
+ ...configs
81
81
  });
82
82
  }
83
83
  /**