@athenna/logger 4.4.0 → 4.6.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,178 +1,179 @@
1
1
  {
2
- "name": "@athenna/logger",
3
- "version": "4.4.0",
4
- "description": "The Athenna logging solution. Log in stdout, files and buckets.",
5
- "license": "MIT",
6
- "author": "João Lenon <lenon@athenna.io>",
7
- "bugs": "https://github.com/AthennaIO/Logger/issues",
8
- "repository": "https://github.com/AthennaIO/Logger.git",
9
- "homepage": "https://github.com/AthennaIO/Logger#readme",
10
- "keywords": [
11
- "slack",
12
- "discord",
13
- "telegram",
14
- "console",
15
- "debug",
16
- "buckets",
17
- "logger",
18
- "drivers",
19
- "formatters",
20
- "athenna",
21
- "esm"
2
+ "name": "@athenna/logger",
3
+ "version": "4.6.0",
4
+ "description": "The Athenna logging solution. Log in stdout, files and buckets.",
5
+ "license": "MIT",
6
+ "author": "João Lenon <lenon@athenna.io>",
7
+ "bugs": "https://github.com/AthennaIO/Logger/issues",
8
+ "repository": "https://github.com/AthennaIO/Logger.git",
9
+ "homepage": "https://github.com/AthennaIO/Logger#readme",
10
+ "keywords": [
11
+ "slack",
12
+ "files",
13
+ "discord",
14
+ "telegram",
15
+ "console",
16
+ "debug",
17
+ "buckets",
18
+ "logger",
19
+ "drivers",
20
+ "formatters",
21
+ "athenna",
22
+ "typescript",
23
+ "esm"
24
+ ],
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ },
28
+ "scripts": {
29
+ "build": "node node_modules/@athenna/tsconfig/src/build.js",
30
+ "lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix",
31
+ "test": "npm run --silent lint:fix && node --import=@athenna/tsconfig bin/test.ts",
32
+ "test:debug": "cross-env NODE_DEBUG=athenna:* node --inspect --import=@athenna/tsconfig bin/test.ts",
33
+ "test:coverage": "c8 npm run --silent test"
34
+ },
35
+ "files": [
36
+ "src/*.js",
37
+ "src/*.d.ts",
38
+ "src/**/*.js",
39
+ "src/**/*.d.ts",
40
+ "templates",
41
+ "configurer"
42
+ ],
43
+ "type": "module",
44
+ "main": "./src/index.js",
45
+ "types": "./src/index.d.ts",
46
+ "exports": {
47
+ ".": "./src/index.js",
48
+ "./types": "./src/types/index.js",
49
+ "./package": "./package.json",
50
+ "./package.json": "./package.json",
51
+ "./providers/LoggerProvider": "./src/providers/LoggerProvider.js"
52
+ },
53
+ "imports": {
54
+ "#bin/*": "./bin/*.js",
55
+ "#bin": "./bin/index.js",
56
+ "#src/*": "./src/*.js",
57
+ "#src": "./src/index.js",
58
+ "#src/types": "./src/types/index.js",
59
+ "#src/debug": "./src/debug/index.js",
60
+ "#tests/*": "./tests/*.js",
61
+ "#tests": "./tests/index.js"
62
+ },
63
+ "dependencies": {
64
+ "telegraf": "^4.13.1",
65
+ "cls-rtracer": "^2.6.3"
66
+ },
67
+ "devDependencies": {
68
+ "@athenna/common": "^4.17.0",
69
+ "@athenna/config": "^4.5.0",
70
+ "@athenna/ioc": "^4.5.0",
71
+ "@athenna/test": "^4.10.0",
72
+ "@athenna/tsconfig": "^4.8.2",
73
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
74
+ "@typescript-eslint/parser": "^6.7.4",
75
+ "commitizen": "^4.2.6",
76
+ "cz-conventional-changelog": "^3.3.0",
77
+ "eslint": "^8.36.0",
78
+ "eslint-config-prettier": "^8.8.0",
79
+ "eslint-config-standard": "^17.0.0",
80
+ "eslint-plugin-import": "^2.27.5",
81
+ "eslint-plugin-n": "^15.6.1",
82
+ "eslint-plugin-prettier": "^4.2.1",
83
+ "eslint-plugin-promise": "^6.1.1",
84
+ "husky": "^3.1.0",
85
+ "lint-staged": "^12.5.0",
86
+ "prettier": "^2.8.7"
87
+ },
88
+ "c8": {
89
+ "all": true,
90
+ "include": [
91
+ "src/**/*.ts"
22
92
  ],
23
- "scripts": {
24
- "build": "rimraf build && tsc --project bin/tsconfig.build.json",
25
- "lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix",
26
- "test": "npm run --silent lint:fix && sh node bin/test.ts",
27
- "test:debug": "cross-env NODE_DEBUG=athenna:* sh node --inspect bin/test.ts",
28
- "test:coverage": "c8 npm run --silent test"
29
- },
30
- "files": [
31
- "src/*.js",
32
- "src/*.d.ts",
33
- "src/**/*.js",
34
- "src/**/*.d.ts",
35
- "templates",
36
- "configurer"
93
+ "exclude": [],
94
+ "reporter": [
95
+ "text-summary",
96
+ "html"
37
97
  ],
38
- "type": "module",
39
- "main": "./src/index.js",
40
- "types": "./src/index.d.ts",
41
- "exports": {
42
- ".": "./src/index.js",
43
- "./types": "./src/types/index.js",
44
- "./package.json": "./package.json",
45
- "./providers/LoggerProvider": "./src/providers/LoggerProvider.js"
46
- },
47
- "imports": {
48
- "#bin/*": "./bin/*.js",
49
- "#bin": "./bin/index.js",
50
- "#src/*": "./src/*.js",
51
- "#src": "./src/index.js",
52
- "#src/types": "./src/types/index.js",
53
- "#src/debug": "./src/debug/index.js",
54
- "#tests/*": "./tests/*.js",
55
- "#tests": "./tests/index.js"
56
- },
57
- "dependencies": {
58
- "telegraf": "^4.12.2",
59
- "cls-rtracer": "^2.6.3"
60
- },
61
- "devDependencies": {
62
- "@athenna/common": "^4.10.1",
63
- "@athenna/config": "^4.4.0",
64
- "@athenna/ioc": "^4.3.0",
65
- "@athenna/test": "^4.7.0",
66
- "@typescript-eslint/eslint-plugin": "^5.56.0",
67
- "@typescript-eslint/parser": "^5.56.0",
68
- "c8": "^7.12.0",
69
- "commitizen": "^4.2.6",
70
- "cross-env": "^7.0.3",
71
- "cz-conventional-changelog": "^3.3.0",
72
- "eslint": "^8.36.0",
73
- "eslint-config-prettier": "^8.8.0",
74
- "eslint-config-standard": "^17.0.0",
75
- "eslint-plugin-import": "^2.27.5",
76
- "eslint-plugin-n": "^15.6.1",
77
- "eslint-plugin-prettier": "^4.2.1",
78
- "eslint-plugin-promise": "^6.1.1",
79
- "husky": "^3.1.0",
80
- "lint-staged": "^12.5.0",
81
- "prettier": "^2.8.7",
82
- "reflect-metadata": "^0.1.13",
83
- "rimraf": "^5.0.1",
84
- "ts-node": "^10.9.1",
85
- "typescript": "^5.0.2"
86
- },
87
- "c8": {
88
- "all": true,
89
- "include": [
90
- "src/**/*.ts"
91
- ],
92
- "exclude": [],
93
- "reporter": [
94
- "text-summary",
95
- "html"
96
- ],
97
- "report-dir": "./tests/coverage",
98
- "check-coverage": true
99
- },
100
- "husky": {
101
- "hooks": {
102
- "prepare-commit-msg": "lint-staged && exec < /dev/tty && git cz --hook || true"
103
- }
104
- },
105
- "lint-staged": {
106
- "*.js": [
107
- "eslint --fix",
108
- "git add"
109
- ],
110
- "*.json": [
111
- "prettier --write",
112
- "git add"
113
- ]
114
- },
115
- "config": {
116
- "commitizen": {
117
- "path": "./node_modules/cz-conventional-changelog"
98
+ "report-dir": "./tests/coverage",
99
+ "check-coverage": true
100
+ },
101
+ "husky": {
102
+ "hooks": {
103
+ "prepare-commit-msg": "lint-staged && exec < /dev/tty && git cz --hook || true"
104
+ }
105
+ },
106
+ "lint-staged": {
107
+ "*.js": [
108
+ "eslint --fix",
109
+ "git add"
110
+ ],
111
+ "*.json": [
112
+ "prettier --write",
113
+ "git add"
114
+ ]
115
+ },
116
+ "config": {
117
+ "commitizen": {
118
+ "path": "./node_modules/cz-conventional-changelog"
119
+ }
120
+ },
121
+ "prettier": {
122
+ "singleQuote": true,
123
+ "trailingComma": "none",
124
+ "arrowParens": "avoid",
125
+ "endOfLine": "lf",
126
+ "semi": false,
127
+ "printWidth": 80,
128
+ "overrides": [
129
+ {
130
+ "files": "tests/**/*",
131
+ "options": {
132
+ "printWidth": 120
118
133
  }
134
+ }
135
+ ]
136
+ },
137
+ "eslintIgnore": [],
138
+ "eslintConfig": {
139
+ "env": {
140
+ "es2021": true,
141
+ "node": true
119
142
  },
120
- "prettier": {
121
- "singleQuote": true,
122
- "trailingComma": "none",
123
- "arrowParens": "avoid",
124
- "endOfLine": "lf",
125
- "semi": false,
126
- "printWidth": 80,
127
- "overrides": [
128
- {
129
- "files": "tests/**/*",
130
- "options": {
131
- "printWidth": 120
132
- }
133
- }
134
- ]
143
+ "globals": {
144
+ "ioc": true,
145
+ "Env": true,
146
+ "Path": true,
147
+ "Config": true,
148
+ "container": true
135
149
  },
136
- "eslintIgnore": [],
137
- "eslintConfig": {
138
- "env": {
139
- "es2021": true,
140
- "node": true
141
- },
142
- "globals": {
143
- "ioc": true,
144
- "Env": true,
145
- "Path": true,
146
- "Config": true,
147
- "container": true
148
- },
149
- "plugins": [
150
- "prettier",
151
- "@typescript-eslint"
152
- ],
153
- "extends": [
154
- "standard",
155
- "eslint:recommended",
156
- "plugin:prettier/recommended",
157
- "plugin:@typescript-eslint/recommended",
158
- "plugin:@typescript-eslint/eslint-recommended"
159
- ],
160
- "parser": "@typescript-eslint/parser",
161
- "rules": {
162
- "camelcase": "off",
163
- "dot-notation": "off",
164
- "prettier/prettier": "error",
165
- "no-useless-constructor": "off",
166
- "@typescript-eslint/no-explicit-any": "off",
167
- "@typescript-eslint/no-empty-function": "off",
168
- "@typescript-eslint/no-unused-vars": [
169
- "error",
170
- {
171
- "argsIgnorePattern": "^_",
172
- "varsIgnorePattern": "^_",
173
- "caughtErrorsIgnorePattern": "^_"
174
- }
175
- ]
150
+ "plugins": [
151
+ "prettier",
152
+ "@typescript-eslint"
153
+ ],
154
+ "extends": [
155
+ "standard",
156
+ "eslint:recommended",
157
+ "plugin:prettier/recommended",
158
+ "plugin:@typescript-eslint/recommended",
159
+ "plugin:@typescript-eslint/eslint-recommended"
160
+ ],
161
+ "parser": "@typescript-eslint/parser",
162
+ "rules": {
163
+ "camelcase": "off",
164
+ "dot-notation": "off",
165
+ "prettier/prettier": "error",
166
+ "no-useless-constructor": "off",
167
+ "@typescript-eslint/no-explicit-any": "off",
168
+ "@typescript-eslint/no-empty-function": "off",
169
+ "@typescript-eslint/no-unused-vars": [
170
+ "error",
171
+ {
172
+ "argsIgnorePattern": "^_",
173
+ "varsIgnorePattern": "^_",
174
+ "caughtErrorsIgnorePattern": "^_"
176
175
  }
176
+ ]
177
177
  }
178
+ }
178
179
  }
@@ -20,7 +20,7 @@ import { TelegramDriver } from '#src/drivers/TelegramDriver';
20
20
  import { DriverExistException } from '#src/exceptions/DriverExistException';
21
21
  import { NotFoundDriverException } from '#src/exceptions/NotFoundDriverException';
22
22
  import { NotImplementedConfigException } from '#src/exceptions/NotImplementedConfigException';
23
- class DriverFactory {
23
+ export class DriverFactory {
24
24
  /**
25
25
  * Drivers of DriverFactory.
26
26
  */
@@ -92,4 +92,3 @@ class DriverFactory {
92
92
  return channelConfig;
93
93
  }
94
94
  }
95
- export { DriverFactory };
@@ -15,7 +15,7 @@ import { MessageFormatter } from '#src/formatters/MessageFormatter';
15
15
  import { RequestFormatter } from '#src/formatters/RequestFormatter';
16
16
  import { FormatterExistException } from '#src/exceptions/FormatterExistException';
17
17
  import { NotFoundFormatterException } from '#src/exceptions/NotFoundFormatterException';
18
- class FormatterFactory {
18
+ export class FormatterFactory {
19
19
  /**
20
20
  * Formatters of FormatterFactory.
21
21
  */
@@ -56,4 +56,3 @@ class FormatterFactory {
56
56
  this.formatters.set(name, { Formatter: formatter });
57
57
  }
58
58
  }
59
- export { FormatterFactory };
@@ -13,18 +13,18 @@ export class RequestFormatter extends Formatter {
13
13
  if (Is.String(ctx)) {
14
14
  return ctx;
15
15
  }
16
- const ip = ctx.request.ip;
17
- const status = ctx.status;
18
16
  const responseTimeMs = `${Math.round(ctx.responseTime)}ms`;
19
- const methodAndStatus = Color[ctx.request.method](`[${ctx.request.method}::${ctx.status}]`);
17
+ const status = Color.statusCode(ctx.status);
18
+ const method = Color.httpMethod(ctx.request.method);
19
+ const date = new Date().toISOString();
20
20
  if (!this.configs.asJson) {
21
- return this.clean(`${methodAndStatus} - [${ip}] - ${new Date().toISOString()} - ${ctx.request.baseUrl} ${responseTimeMs}`);
21
+ return this.clean(`${method}${status} ${ctx.request.baseUrl} - ${date} - ${responseTimeMs}`);
22
22
  }
23
23
  const metadata = {
24
24
  method: ctx.request.method,
25
25
  duration: responseTimeMs,
26
- status: status <= 399 ? 'SUCCESS' : 'ERROR',
27
- statusCode: status,
26
+ status: ctx.status <= 399 ? 'SUCCESS' : 'ERROR',
27
+ statusCode: ctx.status,
28
28
  url: ctx.request.hostUrl,
29
29
  path: ctx.request.baseUrl,
30
30
  createdAt: Date.now(),