@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 +8 -8
- package/src/constants/VanillaChannels.js +9 -9
- package/src/drivers/DiscordDriver.js +1 -1
- package/src/drivers/Driver.js +1 -1
- package/src/drivers/TelegramDriver.js +1 -1
- package/src/exceptions/DriverExistException.js +1 -1
- package/src/exceptions/FormatterExistException.js +1 -1
- package/src/exceptions/NotFoundDriverException.js +1 -1
- package/src/exceptions/NotFoundFormatterException.js +1 -1
- package/src/exceptions/NotImplementedConfigException.js +1 -1
- package/src/factories/DriverFactory.js +1 -1
- package/src/formatters/Formatter.js +3 -3
- package/src/formatters/JsonFormatter.js +1 -1
- package/src/formatters/RequestFormatter.js +3 -3
- package/src/logger/Logger.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/logger",
|
|
3
|
-
"version": "4.
|
|
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.
|
|
63
|
-
"@athenna/config": "^4.
|
|
64
|
-
"@athenna/ioc": "^4.
|
|
65
|
-
"@athenna/test": "^4.
|
|
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": "
|
|
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
|
}
|
package/src/drivers/Driver.js
CHANGED
|
@@ -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;
|
|
@@ -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
|
}
|