@athenna/logger 1.1.8 → 1.2.1
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/LICENSE.md +3 -15
- package/README.md +6 -6
- package/package.json +87 -106
- package/src/Drivers/ConsoleDriver.js +43 -17
- package/src/Drivers/DebugDriver.js +45 -18
- package/src/Drivers/DiscordDriver.js +48 -25
- package/src/Drivers/FileDriver.js +51 -29
- package/src/Drivers/NullDriver.js +19 -7
- package/src/Drivers/PinoDriver.js +83 -61
- package/src/Drivers/SlackDriver.js +45 -22
- package/src/Drivers/TelegramDriver.js +44 -21
- package/src/Exceptions/DriverExistException.js +31 -0
- package/src/Exceptions/FormatterExistException.js +32 -0
- package/src/Exceptions/NotFoundChannelException.js +32 -0
- package/src/Exceptions/NotFoundDriverException.js +22 -10
- package/src/Exceptions/NotFoundFormatterException.js +22 -10
- package/src/Exceptions/OnlyPinoPrettyException.js +19 -10
- package/src/Facades/Log.js +9 -5
- package/src/Factories/DriverFactory.js +98 -56
- package/src/Factories/FormatterFactory.js +67 -37
- package/src/Formatters/CliFormatter.js +21 -22
- package/src/Formatters/JsonFormatter.js +15 -10
- package/src/Formatters/MessageFormatter.js +30 -33
- package/src/Formatters/NestFormatter.js +31 -22
- package/src/Formatters/NoneFormatter.js +21 -0
- package/src/Formatters/RequestFormatter.js +49 -37
- package/src/Formatters/SimpleFormatter.js +30 -33
- package/src/Helpers/ColorHelper.js +259 -0
- package/src/Helpers/FactoryHelper.js +121 -0
- package/src/Providers/LoggerProvider.js +13 -15
- package/src/index.d.ts +383 -0
- package/src/index.js +269 -0
- package/index.d.ts +0 -13
- package/index.js +0 -25
- package/src/Contracts/DefaultDriverConfigs.d.ts +0 -4
- package/src/Contracts/DefaultDriverConfigs.js +0 -2
- package/src/Contracts/DriverContract.d.ts +0 -13
- package/src/Contracts/DriverContract.js +0 -10
- package/src/Contracts/FormatterContract.d.ts +0 -11
- package/src/Contracts/FormatterContract.js +0 -10
- package/src/Contracts/LevelTypes.d.ts +0 -1
- package/src/Contracts/LevelTypes.js +0 -2
- package/src/Drivers/ConsoleDriver.d.ts +0 -19
- package/src/Drivers/DebugDriver.d.ts +0 -19
- package/src/Drivers/DiscordDriver.d.ts +0 -20
- package/src/Drivers/FileDriver.d.ts +0 -19
- package/src/Drivers/NullDriver.d.ts +0 -13
- package/src/Drivers/PinoDriver.d.ts +0 -20
- package/src/Drivers/SlackDriver.d.ts +0 -19
- package/src/Drivers/TelegramDriver.d.ts +0 -21
- package/src/Exceptions/ChannelNotConfiguredException.d.ts +0 -12
- package/src/Exceptions/ChannelNotConfiguredException.js +0 -19
- package/src/Exceptions/DriverAlreadyExistException.d.ts +0 -12
- package/src/Exceptions/DriverAlreadyExistException.js +0 -19
- package/src/Exceptions/FormatterAlreadyExistException.d.ts +0 -12
- package/src/Exceptions/FormatterAlreadyExistException.js +0 -19
- package/src/Exceptions/NotFoundDriverException.d.ts +0 -12
- package/src/Exceptions/NotFoundFormatterException.d.ts +0 -12
- package/src/Exceptions/OnlyPinoPrettyException.d.ts +0 -12
- package/src/Facades/Log.d.ts +0 -10
- package/src/Factories/DriverFactory.d.ts +0 -19
- package/src/Factories/FormatterFactory.d.ts +0 -18
- package/src/Formatters/CliFormatter.d.ts +0 -19
- package/src/Formatters/JsonFormatter.d.ts +0 -16
- package/src/Formatters/MessageFormatter.d.ts +0 -20
- package/src/Formatters/NestFormatter.d.ts +0 -19
- package/src/Formatters/RequestFormatter.d.ts +0 -17
- package/src/Formatters/SimpleFormatter.d.ts +0 -21
- package/src/Logger.d.ts +0 -110
- package/src/Logger.js +0 -216
- package/src/Providers/LoggerProvider.d.ts +0 -17
- package/src/Utils/Color.d.ts +0 -48
- package/src/Utils/Color.js +0 -93
- package/src/Utils/getTimestamp.d.ts +0 -9
- package/src/Utils/getTimestamp.js +0 -23
- package/src/Utils/groupConfigs.d.ts +0 -9
- package/src/Utils/groupConfigs.js +0 -18
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,66 +6,89 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
|
|
10
|
+
import pino from 'pino'
|
|
11
|
+
|
|
12
|
+
import { Config } from '@secjs/utils'
|
|
13
|
+
|
|
14
|
+
import { FactoryHelper } from '#src/index'
|
|
15
|
+
import { OnlyPinoPrettyException } from '#src/Exceptions/OnlyPinoPrettyException'
|
|
16
|
+
|
|
17
|
+
export class PinoDriver {
|
|
18
|
+
/**
|
|
19
|
+
* Holds the configuration set of PinoDriver.
|
|
20
|
+
*
|
|
21
|
+
* @type {import('pino').LoggerOptions & { formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }}
|
|
22
|
+
*/
|
|
23
|
+
configs
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of PinoDriver.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} channel
|
|
29
|
+
* @param {any} [configs]
|
|
30
|
+
* @return {PinoDriver}
|
|
31
|
+
*/
|
|
32
|
+
constructor(channel, configs = {}) {
|
|
33
|
+
const channelConfig = Config.get(`logging.channels.${channel}`)
|
|
34
|
+
|
|
35
|
+
this.configs = FactoryHelper.groupConfigs(configs, channelConfig)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Transport the log.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} message
|
|
42
|
+
* @param {import('pino').LoggerOptions & { formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }} [options]
|
|
43
|
+
* @return {void}
|
|
44
|
+
*/
|
|
45
|
+
transport(message, options = {}) {
|
|
46
|
+
const configs = FactoryHelper.groupConfigs(options, this.configs)
|
|
47
|
+
|
|
48
|
+
configs.customLevels = {
|
|
49
|
+
info: 1,
|
|
50
|
+
warn: 2,
|
|
51
|
+
error: 3,
|
|
52
|
+
debug: 4,
|
|
53
|
+
success: 5,
|
|
54
|
+
critical: 6,
|
|
23
55
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
configs.useOnlyCustomLevels = true;
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
const pinoMethod = configs.formatterConfig.level.toLowerCase();
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
delete configs.formatterConfig.level;
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
delete configs.formatterConfig.chalk;
|
|
43
|
-
if (configs.formatter !== 'pino-pretty') {
|
|
44
|
-
throw new OnlyPinoPrettyException_1.OnlyPinoPrettyException();
|
|
45
|
-
}
|
|
46
|
-
const pinoConfigs = {};
|
|
47
|
-
Object.keys(configs).forEach(key => {
|
|
48
|
-
if (key === 'formatter') {
|
|
49
|
-
pinoConfigs.transport = {
|
|
50
|
-
target: 'pino-pretty',
|
|
51
|
-
options: configs.formatterConfig,
|
|
52
|
-
};
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
configs.formatterConfig.customLevels =
|
|
56
|
-
'info:1,warn:2,error:3,debug:4,success:5';
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
configs.formatterConfig.customColors =
|
|
60
|
-
'info:cyan,warn:yellow,error:red,debug:magenta,success:green';
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (['driver', 'formatterConfig'].includes(key)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
pinoConfigs[key] = configs[key];
|
|
67
|
-
});
|
|
68
|
-
const logger = pino_1.default(pinoConfigs);
|
|
69
|
-
return logger[pinoMethod](message);
|
|
56
|
+
configs.useOnlyCustomLevels = true
|
|
57
|
+
|
|
58
|
+
const pinoMethod = configs.formatterConfig.level.toLowerCase()
|
|
59
|
+
|
|
60
|
+
delete configs.formatterConfig.level
|
|
61
|
+
delete configs.formatterConfig.chalk
|
|
62
|
+
|
|
63
|
+
if (configs.formatter !== 'pino-pretty') {
|
|
64
|
+
throw new OnlyPinoPrettyException()
|
|
70
65
|
}
|
|
66
|
+
|
|
67
|
+
const pinoConfigs = {}
|
|
68
|
+
|
|
69
|
+
Object.keys(configs).forEach(key => {
|
|
70
|
+
if (key === 'formatter') {
|
|
71
|
+
pinoConfigs.transport = {
|
|
72
|
+
target: 'pino-pretty',
|
|
73
|
+
options: configs.formatterConfig,
|
|
74
|
+
}
|
|
75
|
+
configs.formatterConfig.customLevels =
|
|
76
|
+
'info:1,warn:2,error:3,debug:4,success:5,critical:6'
|
|
77
|
+
configs.formatterConfig.customColors =
|
|
78
|
+
'info:cyan,warn:yellow,error:red,debug:magenta,success:green,critical:red'
|
|
79
|
+
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (['driver', 'formatterConfig'].includes(key)) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
pinoConfigs[key] = configs[key]
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const logger = pino(pinoConfigs)
|
|
91
|
+
|
|
92
|
+
logger[pinoMethod](message)
|
|
93
|
+
}
|
|
71
94
|
}
|
|
72
|
-
exports.PinoDriver = PinoDriver;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,25 +6,49 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
|
|
10
|
+
import axios from 'axios'
|
|
11
|
+
|
|
12
|
+
import { Config } from '@secjs/utils'
|
|
13
|
+
|
|
14
|
+
import { ColorHelper, FactoryHelper, FormatterFactory } from '#src/index'
|
|
15
|
+
|
|
16
|
+
export class SlackDriver {
|
|
17
|
+
/**
|
|
18
|
+
* Holds the configuration set of SlackDriver.
|
|
19
|
+
*
|
|
20
|
+
* @type {{ url?: string, formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }}
|
|
21
|
+
*/
|
|
22
|
+
configs
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new instance of SlackDriver.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} channel
|
|
28
|
+
* @param {any} [configs]
|
|
29
|
+
* @return {SlackDriver}
|
|
30
|
+
*/
|
|
31
|
+
constructor(channel, configs = {}) {
|
|
32
|
+
const channelConfig = Config.get(`logging.channels.${channel}`)
|
|
33
|
+
|
|
34
|
+
this.configs = FactoryHelper.groupConfigs(configs, channelConfig)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Transport the log.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} message
|
|
41
|
+
* @param {{ url?: string, formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }} [options]
|
|
42
|
+
* @return {Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
async transport(message, options = {}) {
|
|
45
|
+
const configs = FactoryHelper.groupConfigs(options, this.configs)
|
|
46
|
+
|
|
47
|
+
message = FormatterFactory.fabricate(configs.formatter).format(
|
|
48
|
+
message,
|
|
49
|
+
configs.formatterConfig,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
await axios.post(configs.url, { text: ColorHelper.removeColors(message) })
|
|
53
|
+
}
|
|
30
54
|
}
|
|
31
|
-
exports.SlackDriver = SlackDriver;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,24 +6,48 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TelegramDriver {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
|
|
10
|
+
import { Telegraf } from 'telegraf'
|
|
11
|
+
|
|
12
|
+
import { Config } from '@secjs/utils'
|
|
13
|
+
|
|
14
|
+
import { ColorHelper, FactoryHelper, FormatterFactory } from '#src/index'
|
|
15
|
+
|
|
16
|
+
export class TelegramDriver {
|
|
17
|
+
/**
|
|
18
|
+
* Holds the configuration set of SlackDriver.
|
|
19
|
+
*
|
|
20
|
+
* @type {{ token?: string, chatId?: string|number, parseMode?: 'HTML'|'Markdown'|'MarkdownV2', formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }}
|
|
21
|
+
*/
|
|
22
|
+
configs
|
|
23
|
+
|
|
24
|
+
constructor(channel, configs = {}) {
|
|
25
|
+
const channelConfig = Config.get(`logging.channels.${channel}`)
|
|
26
|
+
|
|
27
|
+
this.configs = FactoryHelper.groupConfigs(configs, channelConfig)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Transport the log.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} message
|
|
34
|
+
* @param {{ token?: string, chatId?: string|number, parseMode?: 'HTML'|'Markdown'|'MarkdownV2', formatter?: 'pino-pretty', formatterConfig?: import('pino-pretty').PrettyOptions }} [options]
|
|
35
|
+
* @return {Promise<void>}
|
|
36
|
+
*/
|
|
37
|
+
async transport(message, options = {}) {
|
|
38
|
+
const configs = FactoryHelper.groupConfigs(options, this.configs)
|
|
39
|
+
|
|
40
|
+
message = FormatterFactory.fabricate(configs.formatter).format(
|
|
41
|
+
message,
|
|
42
|
+
configs.formatterConfig,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
await new Telegraf(configs.token).telegram.sendMessage(
|
|
46
|
+
configs.chatId,
|
|
47
|
+
ColorHelper.removeColors(message),
|
|
48
|
+
{
|
|
49
|
+
parse_mode: configs.parseMode,
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
}
|
|
29
53
|
}
|
|
30
|
-
exports.TelegramDriver = TelegramDriver;
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
10
|
+
import { Exception } from '@secjs/utils'
|
|
11
|
+
import { DriverFactory } from '#src/Factories/DriverFactory'
|
|
12
|
+
|
|
13
|
+
export class DriverExistException extends Exception {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of DriverExistException.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} driverName
|
|
18
|
+
* @return {DriverExistException}
|
|
19
|
+
*/
|
|
20
|
+
constructor(driverName) {
|
|
21
|
+
const content = `The driver ${driverName} already exists in DriverFactory.`
|
|
22
|
+
const availableDrivers = DriverFactory.availableDrivers().join(', ')
|
|
23
|
+
|
|
24
|
+
super(
|
|
25
|
+
content,
|
|
26
|
+
500,
|
|
27
|
+
'E_EXIST_DRIVER',
|
|
28
|
+
`Available drivers are: ${availableDrivers}. The name ${driverName} is already in use inside DriverFactory. Try using a different name for your driver implementation.`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
|
|
10
|
+
import { Exception } from '@secjs/utils'
|
|
11
|
+
import { FormatterFactory } from '#src/Factories/FormatterFactory'
|
|
12
|
+
|
|
13
|
+
export class FormatterExistException extends Exception {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of FormatterExistException.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} formatterName
|
|
18
|
+
* @return {FormatterExistException}
|
|
19
|
+
*/
|
|
20
|
+
constructor(formatterName) {
|
|
21
|
+
const content = `The formatter ${formatterName} already exists in FormatterFactory.`
|
|
22
|
+
const availableFormatters =
|
|
23
|
+
FormatterFactory.availableFormatters().join(', ')
|
|
24
|
+
|
|
25
|
+
super(
|
|
26
|
+
content,
|
|
27
|
+
500,
|
|
28
|
+
'E_EXIST_FORMATTER',
|
|
29
|
+
`Available formatters are: ${availableFormatters}. The name ${formatterName} is already in use inside FormatterFactory. Try using a different name for your formatter implementation.`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
|
|
10
|
+
import { Config, Exception } from '@secjs/utils'
|
|
11
|
+
|
|
12
|
+
export class NotFoundChannelException extends Exception {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of NotFoundChannelException.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} channelName
|
|
17
|
+
* @return {NotFoundChannelException}
|
|
18
|
+
*/
|
|
19
|
+
constructor(channelName) {
|
|
20
|
+
const content = `Channel ${channelName} not found.`
|
|
21
|
+
const availableChannels = Object.keys(Config.get('logging.channels')).join(
|
|
22
|
+
', ',
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
super(
|
|
26
|
+
content,
|
|
27
|
+
500,
|
|
28
|
+
'E_NOT_FOUND',
|
|
29
|
+
`Available channels are: ${availableChannels}. Look into your config/logger file if ${channelName} channel is inside "channels" property, if it does not exist create ${channelName} channel object inside "channels".`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,13 +6,26 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
|
|
10
|
+
import { Exception } from '@secjs/utils'
|
|
11
|
+
import { DriverFactory } from '#src/Factories/DriverFactory'
|
|
12
|
+
|
|
13
|
+
export class NotFoundDriverException extends Exception {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of NotFoundDriverException.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} driverName
|
|
18
|
+
* @return {NotFoundDriverException}
|
|
19
|
+
*/
|
|
20
|
+
constructor(driverName) {
|
|
21
|
+
const content = `The driver ${driverName} has not been found.`
|
|
22
|
+
const availableDrivers = DriverFactory.availableDrivers().join(', ')
|
|
23
|
+
|
|
24
|
+
super(
|
|
25
|
+
content,
|
|
26
|
+
500,
|
|
27
|
+
'E_NOT_FOUND',
|
|
28
|
+
`Available drivers are: ${availableDrivers}. Look into your config/logger file if ${driverName} driver is implemented by logger. Or create ${driverName} driver implementation using DriverFactory.createDriver("${driverName}", ...) method.`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
|
-
exports.NotFoundDriverException = NotFoundDriverException;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,13 +6,26 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
|
|
10
|
+
import { Exception } from '@secjs/utils'
|
|
11
|
+
import { FormatterFactory } from '#src/Factories/FormatterFactory'
|
|
12
|
+
|
|
13
|
+
export class NotFoundFormatterException extends Exception {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of NotFoundFormatterException.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} formatterName
|
|
18
|
+
* @return {NotFoundFormatterException}
|
|
19
|
+
*/
|
|
20
|
+
constructor(formatterName) {
|
|
21
|
+
const content = `The formatter ${formatterName} has not been found.`
|
|
22
|
+
const availableDrivers = FormatterFactory.availableFormatters().join(', ')
|
|
23
|
+
|
|
24
|
+
super(
|
|
25
|
+
content,
|
|
26
|
+
500,
|
|
27
|
+
'E_NOT_FOUND',
|
|
28
|
+
`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.`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
|
-
exports.NotFoundFormatterException = NotFoundFormatterException;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,13 +6,23 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class OnlyPinoPrettyException extends
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
|
|
10
|
+
import { Exception } from '@secjs/utils'
|
|
11
|
+
|
|
12
|
+
export class OnlyPinoPrettyException extends Exception {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of OnlyPinoPrettyException.
|
|
15
|
+
*
|
|
16
|
+
* @return {OnlyPinoPrettyException}
|
|
17
|
+
*/
|
|
18
|
+
constructor() {
|
|
19
|
+
const content = `The driver "pino" can only be used with "pino-pretty" formatter.`
|
|
20
|
+
|
|
21
|
+
super(
|
|
22
|
+
content,
|
|
23
|
+
500,
|
|
24
|
+
'E_PINO_PRETTY',
|
|
25
|
+
`Available formatters are: pino-pretty. Look into your config/logger file where your are using "pino" driver and change the formatter to pino-pretty.`,
|
|
26
|
+
)
|
|
27
|
+
}
|
|
18
28
|
}
|
|
19
|
-
exports.OnlyPinoPrettyException = OnlyPinoPrettyException;
|
package/src/Facades/Log.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @athenna/logger
|
|
4
3
|
*
|
|
@@ -7,7 +6,12 @@
|
|
|
7
6
|
* For the full copyright and license information, please view the LICENSE
|
|
8
7
|
* file that was distributed with this source code.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
|
|
10
|
+
import { Facade } from '@athenna/ioc'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Log facade.
|
|
14
|
+
*
|
|
15
|
+
* @type {Facade & import('../index').Logger}
|
|
16
|
+
*/
|
|
17
|
+
export const Log = Facade.createFor('Athenna/Core/Logger')
|