@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.
Files changed (77) hide show
  1. package/LICENSE.md +3 -15
  2. package/README.md +6 -6
  3. package/package.json +87 -106
  4. package/src/Drivers/ConsoleDriver.js +43 -17
  5. package/src/Drivers/DebugDriver.js +45 -18
  6. package/src/Drivers/DiscordDriver.js +48 -25
  7. package/src/Drivers/FileDriver.js +51 -29
  8. package/src/Drivers/NullDriver.js +19 -7
  9. package/src/Drivers/PinoDriver.js +83 -61
  10. package/src/Drivers/SlackDriver.js +45 -22
  11. package/src/Drivers/TelegramDriver.js +44 -21
  12. package/src/Exceptions/DriverExistException.js +31 -0
  13. package/src/Exceptions/FormatterExistException.js +32 -0
  14. package/src/Exceptions/NotFoundChannelException.js +32 -0
  15. package/src/Exceptions/NotFoundDriverException.js +22 -10
  16. package/src/Exceptions/NotFoundFormatterException.js +22 -10
  17. package/src/Exceptions/OnlyPinoPrettyException.js +19 -10
  18. package/src/Facades/Log.js +9 -5
  19. package/src/Factories/DriverFactory.js +98 -56
  20. package/src/Factories/FormatterFactory.js +67 -37
  21. package/src/Formatters/CliFormatter.js +21 -22
  22. package/src/Formatters/JsonFormatter.js +15 -10
  23. package/src/Formatters/MessageFormatter.js +30 -33
  24. package/src/Formatters/NestFormatter.js +31 -22
  25. package/src/Formatters/NoneFormatter.js +21 -0
  26. package/src/Formatters/RequestFormatter.js +49 -37
  27. package/src/Formatters/SimpleFormatter.js +30 -33
  28. package/src/Helpers/ColorHelper.js +259 -0
  29. package/src/Helpers/FactoryHelper.js +121 -0
  30. package/src/Providers/LoggerProvider.js +13 -15
  31. package/src/index.d.ts +383 -0
  32. package/src/index.js +269 -0
  33. package/index.d.ts +0 -13
  34. package/index.js +0 -25
  35. package/src/Contracts/DefaultDriverConfigs.d.ts +0 -4
  36. package/src/Contracts/DefaultDriverConfigs.js +0 -2
  37. package/src/Contracts/DriverContract.d.ts +0 -13
  38. package/src/Contracts/DriverContract.js +0 -10
  39. package/src/Contracts/FormatterContract.d.ts +0 -11
  40. package/src/Contracts/FormatterContract.js +0 -10
  41. package/src/Contracts/LevelTypes.d.ts +0 -1
  42. package/src/Contracts/LevelTypes.js +0 -2
  43. package/src/Drivers/ConsoleDriver.d.ts +0 -19
  44. package/src/Drivers/DebugDriver.d.ts +0 -19
  45. package/src/Drivers/DiscordDriver.d.ts +0 -20
  46. package/src/Drivers/FileDriver.d.ts +0 -19
  47. package/src/Drivers/NullDriver.d.ts +0 -13
  48. package/src/Drivers/PinoDriver.d.ts +0 -20
  49. package/src/Drivers/SlackDriver.d.ts +0 -19
  50. package/src/Drivers/TelegramDriver.d.ts +0 -21
  51. package/src/Exceptions/ChannelNotConfiguredException.d.ts +0 -12
  52. package/src/Exceptions/ChannelNotConfiguredException.js +0 -19
  53. package/src/Exceptions/DriverAlreadyExistException.d.ts +0 -12
  54. package/src/Exceptions/DriverAlreadyExistException.js +0 -19
  55. package/src/Exceptions/FormatterAlreadyExistException.d.ts +0 -12
  56. package/src/Exceptions/FormatterAlreadyExistException.js +0 -19
  57. package/src/Exceptions/NotFoundDriverException.d.ts +0 -12
  58. package/src/Exceptions/NotFoundFormatterException.d.ts +0 -12
  59. package/src/Exceptions/OnlyPinoPrettyException.d.ts +0 -12
  60. package/src/Facades/Log.d.ts +0 -10
  61. package/src/Factories/DriverFactory.d.ts +0 -19
  62. package/src/Factories/FormatterFactory.d.ts +0 -18
  63. package/src/Formatters/CliFormatter.d.ts +0 -19
  64. package/src/Formatters/JsonFormatter.d.ts +0 -16
  65. package/src/Formatters/MessageFormatter.d.ts +0 -20
  66. package/src/Formatters/NestFormatter.d.ts +0 -19
  67. package/src/Formatters/RequestFormatter.d.ts +0 -17
  68. package/src/Formatters/SimpleFormatter.d.ts +0 -21
  69. package/src/Logger.d.ts +0 -110
  70. package/src/Logger.js +0 -216
  71. package/src/Providers/LoggerProvider.d.ts +0 -17
  72. package/src/Utils/Color.d.ts +0 -48
  73. package/src/Utils/Color.js +0 -93
  74. package/src/Utils/getTimestamp.d.ts +0 -9
  75. package/src/Utils/getTimestamp.js +0 -23
  76. package/src/Utils/groupConfigs.d.ts +0 -9
  77. 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
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.PinoDriver = void 0;
15
- const pino_1 = __importDefault(require("pino"));
16
- const utils_1 = require("@secjs/utils");
17
- const groupConfigs_1 = require("../Utils/groupConfigs");
18
- const OnlyPinoPrettyException_1 = require("../Exceptions/OnlyPinoPrettyException");
19
- class PinoDriver {
20
- constructor(channel, configs = {}) {
21
- const channelConfig = utils_1.Config.get(`logging.channels.${channel}`);
22
- this.configs = groupConfigs_1.groupConfigs(configs, channelConfig);
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
- transport(message, options = {}) {
25
- const configs = groupConfigs_1.groupConfigs(options, this.configs);
26
- configs.customLevels = {
27
- info: 1,
28
- warn: 2,
29
- error: 3,
30
- debug: 4,
31
- success: 5,
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.SlackDriver = void 0;
15
- const axios_1 = __importDefault(require("axios"));
16
- const utils_1 = require("@secjs/utils");
17
- const Color_1 = require("../Utils/Color");
18
- const groupConfigs_1 = require("../Utils/groupConfigs");
19
- const FormatterFactory_1 = require("../Factories/FormatterFactory");
20
- class SlackDriver {
21
- constructor(channel, configs = {}) {
22
- const channelConfig = utils_1.Config.get(`logging.channels.${channel}`);
23
- this.configs = groupConfigs_1.groupConfigs(configs, channelConfig);
24
- }
25
- async transport(message, options = {}) {
26
- const configs = groupConfigs_1.groupConfigs(options, this.configs);
27
- message = FormatterFactory_1.FormatterFactory.fabricate(configs.formatter).format(message, configs.formatterConfig);
28
- await axios_1.default.post(configs.url, { text: Color_1.Color.removeColors(message) });
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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.TelegramDriver = void 0;
12
- const telegraf_1 = require("telegraf");
13
- const utils_1 = require("@secjs/utils");
14
- const Color_1 = require("../Utils/Color");
15
- const groupConfigs_1 = require("../Utils/groupConfigs");
16
- const FormatterFactory_1 = require("../Factories/FormatterFactory");
17
- class TelegramDriver {
18
- constructor(channel, configs = {}) {
19
- const channelConfig = utils_1.Config.get(`logging.channels.${channel}`);
20
- this.configs = groupConfigs_1.groupConfigs(configs, channelConfig);
21
- }
22
- async transport(message, options = {}) {
23
- const configs = groupConfigs_1.groupConfigs(options, this.configs);
24
- message = FormatterFactory_1.FormatterFactory.fabricate(configs.formatter).format(message, configs.formatterConfig);
25
- await new telegraf_1.Telegraf(configs.token).telegram.sendMessage(configs.chatId, Color_1.Color.removeColors(message), {
26
- parse_mode: configs.parseMode,
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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.NotFoundDriverException = void 0;
12
- const utils_1 = require("@secjs/utils");
13
- class NotFoundDriverException extends utils_1.Exception {
14
- constructor(driverName) {
15
- const content = `The driver ${driverName} has not been found`;
16
- super(content, 500, 'NOT_FOUND_ERROR', `Look into your config/logger file if this driver is implemented by logger. Or create this driver implementation using Logger.buildDriver method`);
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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.NotFoundFormatterException = void 0;
12
- const utils_1 = require("@secjs/utils");
13
- class NotFoundFormatterException extends utils_1.Exception {
14
- constructor(formatterName) {
15
- const content = `The formatter ${formatterName} has not been found`;
16
- super(content, 500, 'NOT_FOUND_ERROR', `Look into your config/logger file if this formatter is implemented by logger. Or create this formatter implementation using Logger.buildFormatter method`);
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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.OnlyPinoPrettyException = void 0;
12
- const utils_1 = require("@secjs/utils");
13
- class OnlyPinoPrettyException extends utils_1.Exception {
14
- constructor() {
15
- const content = `The driver "pino" can only be used with "pino-pretty" formatter.`;
16
- super(content, 500, 'ONLY_PINO-PRETTY_EXCEPTION', `Look into your config/logger file the formatter that you are trying to use with your channel configuration.`);
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;
@@ -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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.Log = void 0;
12
- const ioc_1 = require("@athenna/ioc");
13
- exports.Log = ioc_1.Facade.createFor('Athenna/Core/Logger');
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')