@athenna/logger 3.4.0 → 4.1.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 +168 -163
- package/src/{Constants → constants}/VanillaChannels.d.ts +9 -2
- package/src/{Constants → constants}/VanillaChannels.js +9 -2
- package/src/{Facades/Log.d.ts → debug/index.d.ts} +2 -2
- package/src/debug/index.js +10 -0
- package/src/{Drivers → drivers}/ConsoleDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/ConsoleDriver.js +3 -1
- package/src/{Drivers → drivers}/DiscordDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/DiscordDriver.js +3 -1
- package/src/{Drivers → drivers}/Driver.d.ts +1 -1
- package/src/{Drivers → drivers}/Driver.js +34 -34
- package/src/{Drivers → drivers}/FileDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/FileDriver.js +4 -1
- package/src/{Drivers → drivers}/NullDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/NullDriver.js +3 -1
- package/src/{Drivers → drivers}/SlackDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/SlackDriver.js +3 -1
- package/src/{Drivers → drivers}/StackDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/StackDriver.js +4 -2
- package/src/{Drivers → drivers}/TelegramDriver.d.ts +1 -1
- package/src/{Drivers → drivers}/TelegramDriver.js +3 -1
- package/src/{Exceptions → exceptions}/DriverExistException.js +1 -1
- package/src/{Exceptions → exceptions}/FormatterExistException.js +1 -1
- package/src/{Exceptions → exceptions}/NotFoundDriverException.js +1 -1
- package/src/{Exceptions → exceptions}/NotFoundFormatterException.js +1 -1
- package/src/facades/Log.d.ts +10 -0
- package/src/{Facades → facades}/Log.js +1 -0
- package/src/{Factories → factories}/DriverFactory.d.ts +1 -1
- package/src/{Factories → factories}/DriverFactory.js +14 -13
- package/src/{Factories → factories}/FormatterFactory.d.ts +1 -1
- package/src/{Factories → factories}/FormatterFactory.js +11 -10
- package/src/{Formatters → formatters}/CliFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/CliFormatter.js +1 -1
- package/src/{Formatters → formatters}/Formatter.js +6 -4
- package/src/{Formatters → formatters}/JsonFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/JsonFormatter.js +1 -1
- package/src/{Formatters → formatters}/MessageFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/MessageFormatter.js +1 -1
- package/src/{Formatters → formatters}/NoneFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/NoneFormatter.js +1 -1
- package/src/{Formatters → formatters}/RequestFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/RequestFormatter.js +1 -1
- package/src/{Formatters → formatters}/SimpleFormatter.d.ts +1 -1
- package/src/{Formatters → formatters}/SimpleFormatter.js +1 -1
- package/src/index.d.ts +8 -8
- package/src/index.js +8 -8
- package/src/{Logger → logger}/Logger.js +11 -13
- package/src/{Providers → providers}/LoggerProvider.js +1 -1
- /package/src/{Exceptions → exceptions}/DriverExistException.d.ts +0 -0
- /package/src/{Exceptions → exceptions}/FormatterExistException.d.ts +0 -0
- /package/src/{Exceptions → exceptions}/NotFoundDriverException.d.ts +0 -0
- /package/src/{Exceptions → exceptions}/NotFoundFormatterException.d.ts +0 -0
- /package/src/{Exceptions → exceptions}/NotImplementedConfigException.d.ts +0 -0
- /package/src/{Exceptions → exceptions}/NotImplementedConfigException.js +0 -0
- /package/src/{Formatters → formatters}/Formatter.d.ts +0 -0
- /package/src/{Helpers → helpers}/FactoryHelper.d.ts +0 -0
- /package/src/{Helpers → helpers}/FactoryHelper.js +0 -0
- /package/src/{Logger → logger}/Logger.d.ts +0 -0
- /package/src/{Providers → providers}/LoggerProvider.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,172 +1,177 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix",
|
|
25
|
-
"test": "npm run --silent lint:fix && sh node bin/test.ts",
|
|
26
|
-
"test:debug": "cross-env DEBUG=api:* sh node --inspect bin/test.ts",
|
|
27
|
-
"test:coverage": "c8 npm run --silent test"
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"src/*.js",
|
|
31
|
-
"src/*.d.ts",
|
|
32
|
-
"src/**/*.js",
|
|
33
|
-
"src/**/*.d.ts",
|
|
34
|
-
"templates"
|
|
35
|
-
],
|
|
36
|
-
"type": "module",
|
|
37
|
-
"main": "./src/index.js",
|
|
38
|
-
"types": "./src/index.d.ts",
|
|
39
|
-
"exports": {
|
|
40
|
-
".": "./src/index.js",
|
|
41
|
-
"./providers/LoggerProvider": "./src/Providers/LoggerProvider.js"
|
|
42
|
-
},
|
|
43
|
-
"imports": {
|
|
44
|
-
"#bin/*": "./bin/*.js",
|
|
45
|
-
"#bin": "./bin/index.js",
|
|
46
|
-
"#src/*": "./src/*.js",
|
|
47
|
-
"#src": "./src/index.js",
|
|
48
|
-
"#tests/*": "./tests/*.js",
|
|
49
|
-
"#tests": "./tests/index.js"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"telegraf": "^4.12.2",
|
|
53
|
-
"cls-rtracer": "^2.6.2"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@athenna/common": "^3.6.0",
|
|
57
|
-
"@athenna/config": "^3.6.0",
|
|
58
|
-
"@athenna/ioc": "^3.4.0",
|
|
59
|
-
"@athenna/test": "^3.6.0",
|
|
60
|
-
"@swc/core": "^1.3.27",
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
62
|
-
"@typescript-eslint/parser": "^5.56.0",
|
|
63
|
-
"c8": "^7.12.0",
|
|
64
|
-
"commitizen": "^4.2.6",
|
|
65
|
-
"cross-env": "^7.0.3",
|
|
66
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
67
|
-
"eslint": "^8.36.0",
|
|
68
|
-
"eslint-config-prettier": "^8.8.0",
|
|
69
|
-
"eslint-config-standard": "^17.0.0",
|
|
70
|
-
"eslint-plugin-import": "^2.27.5",
|
|
71
|
-
"eslint-plugin-n": "^15.6.1",
|
|
72
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
73
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
74
|
-
"husky": "^3.1.0",
|
|
75
|
-
"lint-staged": "^12.5.0",
|
|
76
|
-
"prettier": "^2.8.7",
|
|
77
|
-
"reflect-metadata": "^0.1.13",
|
|
78
|
-
"ts-node": "^10.9.1",
|
|
79
|
-
"typescript": "^5.0.2"
|
|
80
|
-
},
|
|
81
|
-
"c8": {
|
|
82
|
-
"all": true,
|
|
83
|
-
"include": [
|
|
84
|
-
"src/**/*.ts"
|
|
2
|
+
"name": "@athenna/logger",
|
|
3
|
+
"version": "4.1.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"
|
|
85
22
|
],
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"lint-staged": {
|
|
100
|
-
"*.js": [
|
|
101
|
-
"eslint --fix",
|
|
102
|
-
"git add"
|
|
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"
|
|
103
36
|
],
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
|
|
37
|
+
"type": "module",
|
|
38
|
+
"main": "./src/index.js",
|
|
39
|
+
"types": "./src/index.d.ts",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": "./src/index.js",
|
|
42
|
+
"./providers/LoggerProvider": "./src/providers/LoggerProvider.js",
|
|
43
|
+
"./types": "./src/types/index.js",
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"imports": {
|
|
47
|
+
"#bin/*": "./bin/*.js",
|
|
48
|
+
"#bin": "./bin/index.js",
|
|
49
|
+
"#src/*": "./src/*.js",
|
|
50
|
+
"#src": "./src/index.js",
|
|
51
|
+
"#src/types": "./src/types/index.js",
|
|
52
|
+
"#src/debug": "./src/debug/index.js",
|
|
53
|
+
"#tests/*": "./tests/*.js",
|
|
54
|
+
"#tests": "./tests/index.js"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"telegraf": "^4.12.2",
|
|
58
|
+
"cls-rtracer": "^2.6.3"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@athenna/common": "^4.2.0",
|
|
62
|
+
"@athenna/config": "^4.2.0",
|
|
63
|
+
"@athenna/ioc": "^4.0.0",
|
|
64
|
+
"@athenna/test": "^4.2.0",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
66
|
+
"@typescript-eslint/parser": "^5.56.0",
|
|
67
|
+
"c8": "^7.12.0",
|
|
68
|
+
"commitizen": "^4.2.6",
|
|
69
|
+
"cross-env": "^7.0.3",
|
|
70
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
71
|
+
"eslint": "^8.36.0",
|
|
72
|
+
"eslint-config-prettier": "^8.8.0",
|
|
73
|
+
"eslint-config-standard": "^17.0.0",
|
|
74
|
+
"eslint-plugin-import": "^2.27.5",
|
|
75
|
+
"eslint-plugin-n": "^15.6.1",
|
|
76
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
77
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
78
|
+
"husky": "^3.1.0",
|
|
79
|
+
"lint-staged": "^12.5.0",
|
|
80
|
+
"prettier": "^2.8.7",
|
|
81
|
+
"reflect-metadata": "^0.1.13",
|
|
82
|
+
"rimraf": "^5.0.1",
|
|
83
|
+
"ts-node": "^10.9.1",
|
|
84
|
+
"typescript": "^5.0.2"
|
|
85
|
+
},
|
|
86
|
+
"c8": {
|
|
87
|
+
"all": true,
|
|
88
|
+
"include": [
|
|
89
|
+
"src/**/*.ts"
|
|
90
|
+
],
|
|
91
|
+
"exclude": [],
|
|
92
|
+
"reporter": [
|
|
93
|
+
"text-summary",
|
|
94
|
+
"html"
|
|
95
|
+
],
|
|
96
|
+
"report-dir": "./tests/coverage",
|
|
97
|
+
"check-coverage": true
|
|
98
|
+
},
|
|
99
|
+
"husky": {
|
|
100
|
+
"hooks": {
|
|
101
|
+
"prepare-commit-msg": "lint-staged && exec < /dev/tty && git cz --hook || true"
|
|
126
102
|
}
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
"eslintIgnore": [],
|
|
131
|
-
"eslintConfig": {
|
|
132
|
-
"env": {
|
|
133
|
-
"es2021": true,
|
|
134
|
-
"node": true
|
|
135
103
|
},
|
|
136
|
-
"
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
104
|
+
"lint-staged": {
|
|
105
|
+
"*.js": [
|
|
106
|
+
"eslint --fix",
|
|
107
|
+
"git add"
|
|
108
|
+
],
|
|
109
|
+
"*.json": [
|
|
110
|
+
"prettier --write",
|
|
111
|
+
"git add"
|
|
112
|
+
]
|
|
142
113
|
},
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
114
|
+
"config": {
|
|
115
|
+
"commitizen": {
|
|
116
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"prettier": {
|
|
120
|
+
"singleQuote": true,
|
|
121
|
+
"trailingComma": "all",
|
|
122
|
+
"arrowParens": "avoid",
|
|
123
|
+
"endOfLine": "lf",
|
|
124
|
+
"semi": false,
|
|
125
|
+
"printWidth": 80,
|
|
126
|
+
"overrides": [
|
|
127
|
+
{
|
|
128
|
+
"files": "tests/**/*",
|
|
129
|
+
"options": {
|
|
130
|
+
"printWidth": 120
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
"eslintIgnore": [],
|
|
136
|
+
"eslintConfig": {
|
|
137
|
+
"env": {
|
|
138
|
+
"es2021": true,
|
|
139
|
+
"node": true
|
|
140
|
+
},
|
|
141
|
+
"globals": {
|
|
142
|
+
"ioc": true,
|
|
143
|
+
"Env": true,
|
|
144
|
+
"Path": true,
|
|
145
|
+
"Config": true,
|
|
146
|
+
"container": true
|
|
147
|
+
},
|
|
148
|
+
"plugins": [
|
|
149
|
+
"prettier",
|
|
150
|
+
"@typescript-eslint"
|
|
151
|
+
],
|
|
152
|
+
"extends": [
|
|
153
|
+
"standard",
|
|
154
|
+
"eslint:recommended",
|
|
155
|
+
"plugin:prettier/recommended",
|
|
156
|
+
"plugin:@typescript-eslint/recommended",
|
|
157
|
+
"plugin:@typescript-eslint/eslint-recommended"
|
|
158
|
+
],
|
|
159
|
+
"parser": "@typescript-eslint/parser",
|
|
160
|
+
"rules": {
|
|
161
|
+
"camelcase": "off",
|
|
162
|
+
"dot-notation": "off",
|
|
163
|
+
"prettier/prettier": "error",
|
|
164
|
+
"no-useless-constructor": "off",
|
|
165
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
166
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
167
|
+
"@typescript-eslint/no-unused-vars": [
|
|
168
|
+
"error",
|
|
169
|
+
{
|
|
170
|
+
"argsIgnorePattern": "^_",
|
|
171
|
+
"varsIgnorePattern": "^_",
|
|
172
|
+
"caughtErrorsIgnorePattern": "^_"
|
|
173
|
+
}
|
|
174
|
+
]
|
|
168
175
|
}
|
|
169
|
-
]
|
|
170
176
|
}
|
|
171
|
-
}
|
|
172
177
|
}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Athenna default vanilla channels. This
|
|
10
|
+
* Athenna default vanilla channels. This configuration
|
|
11
11
|
* will be used by the "channelOrVanilla" method. If the
|
|
12
|
-
* configuration does not exist,
|
|
12
|
+
* configuration does not exist, then the vanilla will be set.
|
|
13
13
|
*/
|
|
14
14
|
export declare const VANILLA_CHANNELS: {
|
|
15
15
|
default: {
|
|
@@ -23,6 +23,13 @@ export declare const VANILLA_CHANNELS: {
|
|
|
23
23
|
discard: {
|
|
24
24
|
driver: string;
|
|
25
25
|
};
|
|
26
|
+
file: {
|
|
27
|
+
driver: string;
|
|
28
|
+
level: string;
|
|
29
|
+
filePath: string;
|
|
30
|
+
formatter: string;
|
|
31
|
+
formatterConfig: {};
|
|
32
|
+
};
|
|
26
33
|
console: {
|
|
27
34
|
level: string;
|
|
28
35
|
formatter: string;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Athenna default vanilla channels. This
|
|
10
|
+
* Athenna default vanilla channels. This configuration
|
|
11
11
|
* will be used by the "channelOrVanilla" method. If the
|
|
12
|
-
* configuration does not exist,
|
|
12
|
+
* configuration does not exist, then the vanilla will be set.
|
|
13
13
|
*/
|
|
14
14
|
export const VANILLA_CHANNELS = {
|
|
15
15
|
default: {
|
|
@@ -23,6 +23,13 @@ export const VANILLA_CHANNELS = {
|
|
|
23
23
|
discard: {
|
|
24
24
|
driver: 'null',
|
|
25
25
|
},
|
|
26
|
+
file: {
|
|
27
|
+
driver: 'file',
|
|
28
|
+
level: 'trace',
|
|
29
|
+
filePath: Path.logs('athenna.log'),
|
|
30
|
+
formatter: 'simple',
|
|
31
|
+
formatterConfig: {},
|
|
32
|
+
},
|
|
26
33
|
console: {
|
|
27
34
|
level: 'trace',
|
|
28
35
|
formatter: 'cli',
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
9
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
10
|
+
export declare const debug: import("util").DebugLogger;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @athenna/logger
|
|
3
|
+
*
|
|
4
|
+
* (c) João Lenon <lenon@athenna.io>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import { debuglog } from 'node:util';
|
|
10
|
+
export const debug = debuglog('athenna:logger');
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class ConsoleDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): any;
|
|
12
12
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { debug } from '#src/debug';
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
11
|
export class ConsoleDriver extends Driver {
|
|
11
12
|
transport(level, message) {
|
|
12
13
|
if (!this.couldBeTransported(level)) {
|
|
@@ -14,6 +15,7 @@ export class ConsoleDriver extends Driver {
|
|
|
14
15
|
}
|
|
15
16
|
const formatted = this.format(level, message);
|
|
16
17
|
const streamType = this.getStreamTypeFor(level);
|
|
18
|
+
debug('[%s] Transporting logs in %s stream.', ConsoleDriver.name, streamType);
|
|
17
19
|
return process[streamType].write(`${formatted}\n`);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class DiscordDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): Promise<any>;
|
|
12
12
|
}
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { HttpClient } from '@athenna/common';
|
|
10
|
-
import { Driver } from '#src/
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
11
|
+
import { debug } from '#src/debug';
|
|
11
12
|
export class DiscordDriver extends Driver {
|
|
12
13
|
async transport(level, message) {
|
|
13
14
|
if (!this.couldBeTransported(level)) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const formatted = this.format(level, message, true);
|
|
18
|
+
debug('[%s] Transporting logs with username %s and in url %s.', DiscordDriver.name, this.configs.username, this.configs.url);
|
|
17
19
|
return HttpClient.builder(true).post(this.configs.url, {
|
|
18
20
|
username: this.configs.username,
|
|
19
21
|
content: formatted,
|
|
@@ -7,42 +7,42 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Json } from '@athenna/common';
|
|
10
|
-
import { FormatterFactory } from '#src/
|
|
10
|
+
import { FormatterFactory } from '#src/factories/FormatterFactory';
|
|
11
11
|
export class Driver {
|
|
12
|
-
/**
|
|
13
|
-
* Holds the configuration object itself.
|
|
14
|
-
*/
|
|
15
|
-
configs = {};
|
|
16
|
-
/**
|
|
17
|
-
* Holds the configuration object of driver,
|
|
18
|
-
*/
|
|
19
|
-
driverConfig = {};
|
|
20
|
-
/**
|
|
21
|
-
* Holds the formatter string value.
|
|
22
|
-
*/
|
|
23
|
-
formatter = 'none';
|
|
24
|
-
/**
|
|
25
|
-
* Holds the configuration object of formatter.
|
|
26
|
-
*/
|
|
27
|
-
formatterConfig = {};
|
|
28
|
-
/**
|
|
29
|
-
* The max log level that this driver can transport.
|
|
30
|
-
*/
|
|
31
|
-
level = 'info';
|
|
32
|
-
/**
|
|
33
|
-
* The log level order to check if log could
|
|
34
|
-
* be transported or not.
|
|
35
|
-
*/
|
|
36
|
-
levelOrder = [
|
|
37
|
-
'trace',
|
|
38
|
-
'debug',
|
|
39
|
-
'info',
|
|
40
|
-
'success',
|
|
41
|
-
'warn',
|
|
42
|
-
'error',
|
|
43
|
-
'fatal',
|
|
44
|
-
];
|
|
45
12
|
constructor(configs = {}) {
|
|
13
|
+
/**
|
|
14
|
+
* Holds the configuration object itself.
|
|
15
|
+
*/
|
|
16
|
+
this.configs = {};
|
|
17
|
+
/**
|
|
18
|
+
* Holds the configuration object of a driver.
|
|
19
|
+
*/
|
|
20
|
+
this.driverConfig = {};
|
|
21
|
+
/**
|
|
22
|
+
* Holds the formatter string value.
|
|
23
|
+
*/
|
|
24
|
+
this.formatter = 'none';
|
|
25
|
+
/**
|
|
26
|
+
* Holds the configuration object of formatter.
|
|
27
|
+
*/
|
|
28
|
+
this.formatterConfig = {};
|
|
29
|
+
/**
|
|
30
|
+
* The max log level that this driver can transport.
|
|
31
|
+
*/
|
|
32
|
+
this.level = 'info';
|
|
33
|
+
/**
|
|
34
|
+
* The log level order to check if log could
|
|
35
|
+
* be transported or not.
|
|
36
|
+
*/
|
|
37
|
+
this.levelOrder = [
|
|
38
|
+
'trace',
|
|
39
|
+
'debug',
|
|
40
|
+
'info',
|
|
41
|
+
'success',
|
|
42
|
+
'warn',
|
|
43
|
+
'error',
|
|
44
|
+
'fatal',
|
|
45
|
+
];
|
|
46
46
|
this.configs = configs;
|
|
47
47
|
const json = Json.copy(configs);
|
|
48
48
|
delete json.formatter;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class FileDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): Promise<any>;
|
|
12
12
|
}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { File } from '@athenna/common';
|
|
10
|
-
import { Driver } from '#src/
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
11
|
+
import { debug } from '#src/debug';
|
|
11
12
|
export class FileDriver extends Driver {
|
|
12
13
|
async transport(level, message) {
|
|
13
14
|
if (!this.couldBeTransported(level)) {
|
|
@@ -16,7 +17,9 @@ export class FileDriver extends Driver {
|
|
|
16
17
|
const filePath = this.driverConfig.filePath;
|
|
17
18
|
const formatted = this.format(level, message, true);
|
|
18
19
|
const buffer = Buffer.from(`${formatted}\n`, 'utf-8');
|
|
20
|
+
debug('[%s] Transporting logs in %s file path.', FileDriver.name, filePath);
|
|
19
21
|
if (await File.exists(filePath)) {
|
|
22
|
+
debug('[%s] File already exist, appending the data to it.', FileDriver.name);
|
|
20
23
|
return new File(filePath).append(buffer);
|
|
21
24
|
}
|
|
22
25
|
return new File(filePath, buffer).load();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class NullDriver extends Driver {
|
|
11
11
|
transport(): any;
|
|
12
12
|
}
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { debug } from '#src/debug';
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
11
|
export class NullDriver extends Driver {
|
|
11
12
|
transport() {
|
|
13
|
+
debug('[%s] Ignoring log messages.', NullDriver.name);
|
|
12
14
|
return null;
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class SlackDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): Promise<any>;
|
|
12
12
|
}
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
9
10
|
import { HttpClient } from '@athenna/common';
|
|
10
|
-
import {
|
|
11
|
+
import { debug } from '#src/debug';
|
|
11
12
|
export class SlackDriver extends Driver {
|
|
12
13
|
async transport(level, message) {
|
|
13
14
|
if (!this.couldBeTransported(level)) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const formatted = this.format(level, message, true);
|
|
18
|
+
debug('[%s] Transporting logs in url %s.', SlackDriver.name, this.configs.url);
|
|
17
19
|
return HttpClient.builder(true).post(this.configs.url, { text: formatted });
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class StackDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): Promise<any>;
|
|
12
12
|
}
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Json } from '@athenna/common';
|
|
10
|
-
import { Driver } from '#src/
|
|
11
|
-
import { DriverFactory } from '#src/
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
11
|
+
import { DriverFactory } from '#src/factories/DriverFactory';
|
|
12
|
+
import { debug } from '#src/debug';
|
|
12
13
|
export class StackDriver extends Driver {
|
|
13
14
|
transport(level, message) {
|
|
14
15
|
const configs = Json.copy(this.configs);
|
|
15
16
|
delete configs.driver;
|
|
16
17
|
delete configs.channels;
|
|
18
|
+
debug('[%s] Transporting logs in channels: %s.', StackDriver.name, this.driverConfig.channels.join(', '));
|
|
17
19
|
return Promise.all(this.driverConfig.channels.map(c => DriverFactory.fabricate(c, configs).transport(level, message)));
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class TelegramDriver extends Driver {
|
|
11
11
|
transport(level: string, message: any): Promise<any>;
|
|
12
12
|
}
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Telegraf } from 'telegraf';
|
|
10
|
-
import { Driver } from '#src/
|
|
10
|
+
import { Driver } from '#src/drivers/Driver';
|
|
11
|
+
import { debug } from '#src/debug';
|
|
11
12
|
export class TelegramDriver extends Driver {
|
|
12
13
|
async transport(level, message) {
|
|
13
14
|
if (!this.couldBeTransported(level)) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const formatted = this.format(level, message, true);
|
|
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);
|
|
17
19
|
return new Telegraf(this.driverConfig.token).telegram.sendMessage(this.driverConfig.chatId, formatted, {
|
|
18
20
|
parse_mode: this.driverConfig.parseMode,
|
|
19
21
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Exception } from '@athenna/common';
|
|
10
|
-
import { DriverFactory } from '#src/
|
|
10
|
+
import { DriverFactory } from '#src/factories/DriverFactory';
|
|
11
11
|
export class DriverExistException extends Exception {
|
|
12
12
|
constructor(driverName) {
|
|
13
13
|
const availableDrivers = DriverFactory.availableDrivers().join(', ');
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Exception } from '@athenna/common';
|
|
10
|
-
import { FormatterFactory } from '#src/
|
|
10
|
+
import { FormatterFactory } from '#src/factories/FormatterFactory';
|
|
11
11
|
export class FormatterExistException extends Exception {
|
|
12
12
|
constructor(formatterName) {
|
|
13
13
|
const availableFormatters = FormatterFactory.availableFormatters().join(', ');
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Exception, Path } from '@athenna/common';
|
|
10
|
-
import { DriverFactory } from '#src/
|
|
10
|
+
import { DriverFactory } from '#src/factories/DriverFactory';
|
|
11
11
|
export class NotFoundDriverException extends Exception {
|
|
12
12
|
constructor(driverName) {
|
|
13
13
|
const availableDrivers = DriverFactory.availableDrivers().join(', ');
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Exception } from '@athenna/common';
|
|
10
|
-
import { FormatterFactory } from '#src/
|
|
10
|
+
import { FormatterFactory } from '#src/factories/FormatterFactory';
|
|
11
11
|
export class NotFoundFormatterException extends Exception {
|
|
12
12
|
constructor(formatterName) {
|
|
13
13
|
const availableDrivers = FormatterFactory.availableFormatters().join(', ');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @athenna/logger
|
|
3
|
+
*
|
|
4
|
+
* (c) João Lenon <lenon@athenna.io>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import { Logger } from '#src/logger/Logger';
|
|
10
|
+
export declare const Log: import("@athenna/ioc/types").FacadeType<Logger>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Driver } from '#src/
|
|
9
|
+
import { Driver } from '#src/drivers/Driver';
|
|
10
10
|
export declare class DriverFactory {
|
|
11
11
|
/**
|
|
12
12
|
* Drivers of DriverFactory.
|
|
@@ -8,29 +8,30 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Config } from '@athenna/config';
|
|
10
10
|
import { Options } from '@athenna/common';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
11
|
+
import { Driver } from '#src/drivers/Driver';
|
|
12
|
+
import { FileDriver } from '#src/drivers/FileDriver';
|
|
13
|
+
import { NullDriver } from '#src/drivers/NullDriver';
|
|
14
|
+
import { SlackDriver } from '#src/drivers/SlackDriver';
|
|
15
|
+
import { StackDriver } from '#src/drivers/StackDriver';
|
|
16
|
+
import { ConsoleDriver } from '#src/drivers/ConsoleDriver';
|
|
17
|
+
import { DiscordDriver } from '#src/drivers/DiscordDriver';
|
|
18
|
+
import { FactoryHelper } from '#src/helpers/FactoryHelper';
|
|
19
|
+
import { TelegramDriver } from '#src/drivers/TelegramDriver';
|
|
20
|
+
import { DriverExistException } from '#src/exceptions/DriverExistException';
|
|
21
|
+
import { NotFoundDriverException } from '#src/exceptions/NotFoundDriverException';
|
|
22
|
+
import { NotImplementedConfigException } from '#src/exceptions/NotImplementedConfigException';
|
|
22
23
|
class DriverFactory {
|
|
23
24
|
/**
|
|
24
25
|
* Drivers of DriverFactory.
|
|
25
26
|
*/
|
|
26
|
-
static drivers = new Map()
|
|
27
|
+
static { this.drivers = new Map()
|
|
27
28
|
.set('file', { Driver: FileDriver })
|
|
28
29
|
.set('null', { Driver: NullDriver })
|
|
29
30
|
.set('slack', { Driver: SlackDriver })
|
|
30
31
|
.set('stack', { Driver: StackDriver })
|
|
31
32
|
.set('console', { Driver: ConsoleDriver })
|
|
32
33
|
.set('discord', { Driver: DiscordDriver })
|
|
33
|
-
.set('telegram', { Driver: TelegramDriver });
|
|
34
|
+
.set('telegram', { Driver: TelegramDriver }); }
|
|
34
35
|
/**
|
|
35
36
|
* Return an array with all available drivers.
|
|
36
37
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class FormatterFactory {
|
|
11
11
|
/**
|
|
12
12
|
* Formatters of FormatterFactory.
|
|
@@ -6,25 +6,26 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
|
+
import { CliFormatter } from '#src/formatters/CliFormatter';
|
|
11
|
+
import { JsonFormatter } from '#src/formatters/JsonFormatter';
|
|
12
|
+
import { NoneFormatter } from '#src/formatters/NoneFormatter';
|
|
13
|
+
import { SimpleFormatter } from '#src/formatters/SimpleFormatter';
|
|
14
|
+
import { MessageFormatter } from '#src/formatters/MessageFormatter';
|
|
15
|
+
import { RequestFormatter } from '#src/formatters/RequestFormatter';
|
|
16
|
+
import { FormatterExistException } from '#src/exceptions/FormatterExistException';
|
|
17
|
+
import { NotFoundFormatterException } from '#src/exceptions/NotFoundFormatterException';
|
|
17
18
|
class FormatterFactory {
|
|
18
19
|
/**
|
|
19
20
|
* Formatters of FormatterFactory.
|
|
20
21
|
*/
|
|
21
|
-
static formatters = new Map()
|
|
22
|
+
static { this.formatters = new Map()
|
|
22
23
|
.set('cli', { Formatter: CliFormatter })
|
|
23
24
|
.set('json', { Formatter: JsonFormatter })
|
|
24
25
|
.set('none', { Formatter: NoneFormatter })
|
|
25
26
|
.set('simple', { Formatter: SimpleFormatter })
|
|
26
27
|
.set('message', { Formatter: MessageFormatter })
|
|
27
|
-
.set('request', { Formatter: RequestFormatter });
|
|
28
|
+
.set('request', { Formatter: RequestFormatter }); }
|
|
28
29
|
/**
|
|
29
30
|
* Return an array with all available formatters.
|
|
30
31
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class CliFormatter extends Formatter {
|
|
11
11
|
format(message: string): string;
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export class CliFormatter extends Formatter {
|
|
11
11
|
format(message) {
|
|
12
12
|
const level = this.cliLevel();
|
|
@@ -10,10 +10,12 @@ import rTracer from 'cls-rtracer';
|
|
|
10
10
|
import { hostname } from 'node:os';
|
|
11
11
|
import { Is, Color } from '@athenna/common';
|
|
12
12
|
export class Formatter {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
constructor() {
|
|
14
|
+
/**
|
|
15
|
+
* Holds the configuration object of formatter.
|
|
16
|
+
*/
|
|
17
|
+
this.configs = {};
|
|
18
|
+
}
|
|
17
19
|
/**
|
|
18
20
|
* Creates a new instance of Formatter.
|
|
19
21
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class JsonFormatter extends Formatter {
|
|
11
11
|
format(message: any): string;
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Is } from '@athenna/common';
|
|
10
|
-
import { Formatter } from '#src/
|
|
10
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
11
11
|
export class JsonFormatter extends Formatter {
|
|
12
12
|
format(message) {
|
|
13
13
|
const base = {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class MessageFormatter extends Formatter {
|
|
11
11
|
format(message: string): string;
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export class MessageFormatter extends Formatter {
|
|
11
11
|
format(message) {
|
|
12
12
|
return this.clean(`${this.messageLevel()} - (${this.pid()}) - (${this.hostname()}): ${this.toString(message)}`);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class NoneFormatter extends Formatter {
|
|
11
11
|
format(message: string): string;
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export class NoneFormatter extends Formatter {
|
|
11
11
|
format(message) {
|
|
12
12
|
return this.clean(this.applyColorsByChalk(this.toString(message)));
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class RequestFormatter extends Formatter {
|
|
11
11
|
format(ctx: any): string;
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Color, Is } from '@athenna/common';
|
|
10
|
-
import { Formatter } from '#src/
|
|
10
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
11
11
|
export class RequestFormatter extends Formatter {
|
|
12
12
|
format(ctx) {
|
|
13
13
|
if (Is.String(ctx)) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export declare class SimpleFormatter extends Formatter {
|
|
11
11
|
format(message: string): string;
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Formatter } from '#src/
|
|
9
|
+
import { Formatter } from '#src/formatters/Formatter';
|
|
10
10
|
export class SimpleFormatter extends Formatter {
|
|
11
11
|
format(message) {
|
|
12
12
|
const pid = this.pid();
|
package/src/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
9
|
+
export * from './facades/Log.js';
|
|
10
|
+
export * from './logger/Logger.js';
|
|
11
|
+
export * from './drivers/Driver.js';
|
|
12
|
+
export * from './formatters/Formatter.js';
|
|
13
|
+
export * from './helpers/FactoryHelper.js';
|
|
14
|
+
export * from './factories/DriverFactory.js';
|
|
15
|
+
export * from './providers/LoggerProvider.js';
|
|
16
|
+
export * from './factories/FormatterFactory.js';
|
package/src/index.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
9
|
+
export * from './facades/Log.js';
|
|
10
|
+
export * from './logger/Logger.js';
|
|
11
|
+
export * from './drivers/Driver.js';
|
|
12
|
+
export * from './formatters/Formatter.js';
|
|
13
|
+
export * from './helpers/FactoryHelper.js';
|
|
14
|
+
export * from './factories/DriverFactory.js';
|
|
15
|
+
export * from './providers/LoggerProvider.js';
|
|
16
|
+
export * from './factories/FormatterFactory.js';
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Color } from '@athenna/common';
|
|
10
10
|
import { Config } from '@athenna/config';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Driver } from '#src/drivers/Driver';
|
|
12
|
+
import { DriverFactory } from '#src/factories/DriverFactory';
|
|
13
|
+
import { VANILLA_CHANNELS } from '#src/constants/VanillaChannels';
|
|
13
14
|
export class Logger {
|
|
14
|
-
/**
|
|
15
|
-
* The drivers responsible for transporting the logs.
|
|
16
|
-
*/
|
|
17
|
-
drivers = [];
|
|
18
|
-
/**
|
|
19
|
-
* Runtime configurations to be used inside the Drivers and Formatters.
|
|
20
|
-
*/
|
|
21
|
-
runtimeConfigs = {};
|
|
22
15
|
constructor() {
|
|
16
|
+
/**
|
|
17
|
+
* The drivers responsible for transporting the logs.
|
|
18
|
+
*/
|
|
19
|
+
this.drivers = [];
|
|
20
|
+
/**
|
|
21
|
+
* Runtime configurations to be used inside the Drivers and Formatters.
|
|
22
|
+
*/
|
|
23
|
+
this.runtimeConfigs = {};
|
|
23
24
|
this.channelOrVanilla(Config.get('logging.default'));
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
@@ -71,9 +72,6 @@ export class Logger {
|
|
|
71
72
|
* use the default vanilla configurations as drivers.
|
|
72
73
|
*/
|
|
73
74
|
channelOrVanilla(channel, configs = {}) {
|
|
74
|
-
if (channel === 'default') {
|
|
75
|
-
channel = Config.get(`logging.channels.${Config.get('logging.default')}`, 'default');
|
|
76
|
-
}
|
|
77
75
|
if (Config.exists(`logging.channels.${channel}`)) {
|
|
78
76
|
return this.channel(channel);
|
|
79
77
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Logger } from '#src/
|
|
9
|
+
import { Logger } from '#src/logger/Logger';
|
|
10
10
|
import { ServiceProvider } from '@athenna/ioc';
|
|
11
11
|
export class LoggerProvider extends ServiceProvider {
|
|
12
12
|
register() {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|