@athenna/logger 3.0.9 → 3.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.
Files changed (85) hide show
  1. package/build/Drivers/ConsoleDriver.d.ts +12 -0
  2. package/build/Drivers/ConsoleDriver.js +19 -0
  3. package/build/Drivers/DiscordDriver.d.ts +12 -0
  4. package/build/Drivers/DiscordDriver.js +22 -0
  5. package/build/Drivers/Driver.d.ts +52 -0
  6. package/build/Drivers/Driver.js +85 -0
  7. package/build/Drivers/FileDriver.d.ts +12 -0
  8. package/build/Drivers/FileDriver.js +24 -0
  9. package/build/Drivers/NullDriver.d.ts +12 -0
  10. package/build/Drivers/NullDriver.js +14 -0
  11. package/build/Drivers/SlackDriver.d.ts +12 -0
  12. package/build/Drivers/SlackDriver.js +19 -0
  13. package/build/Drivers/StackDriver.d.ts +12 -0
  14. package/build/Drivers/StackDriver.js +19 -0
  15. package/build/Drivers/TelegramDriver.d.ts +12 -0
  16. package/build/Drivers/TelegramDriver.js +21 -0
  17. package/build/Exceptions/DriverExistException.d.ts +12 -0
  18. package/build/Exceptions/DriverExistException.js +21 -0
  19. package/{src/Facades/Log.js → build/Exceptions/FormatterExistException.d.ts} +4 -9
  20. package/build/Exceptions/FormatterExistException.js +21 -0
  21. package/build/Exceptions/NotFoundDriverException.d.ts +12 -0
  22. package/build/Exceptions/NotFoundDriverException.js +21 -0
  23. package/build/Exceptions/NotFoundFormatterException.d.ts +12 -0
  24. package/build/Exceptions/NotFoundFormatterException.js +21 -0
  25. package/build/Exceptions/NotImplementedConfigException.d.ts +12 -0
  26. package/build/Exceptions/NotImplementedConfigException.js +28 -0
  27. package/build/Facades/Log.d.ts +10 -0
  28. package/build/Facades/Log.js +10 -0
  29. package/build/Factories/DriverFactory.d.ts +39 -0
  30. package/build/Factories/DriverFactory.js +93 -0
  31. package/build/Factories/FormatterFactory.d.ts +29 -0
  32. package/build/Factories/FormatterFactory.js +57 -0
  33. package/build/Formatters/CliFormatter.d.ts +12 -0
  34. package/build/Formatters/CliFormatter.js +15 -0
  35. package/build/Formatters/Formatter.d.ts +85 -0
  36. package/build/Formatters/Formatter.js +177 -0
  37. package/build/Formatters/JsonFormatter.d.ts +12 -0
  38. package/build/Formatters/JsonFormatter.js +26 -0
  39. package/build/Formatters/MessageFormatter.d.ts +12 -0
  40. package/build/Formatters/MessageFormatter.js +14 -0
  41. package/build/Formatters/NoneFormatter.d.ts +12 -0
  42. package/{src → build}/Formatters/NoneFormatter.js +4 -12
  43. package/build/Formatters/RequestFormatter.d.ts +12 -0
  44. package/build/Formatters/RequestFormatter.js +45 -0
  45. package/build/Formatters/SimpleFormatter.d.ts +12 -0
  46. package/build/Formatters/SimpleFormatter.js +18 -0
  47. package/build/Helpers/ColorHelper.d.ts +131 -0
  48. package/build/Helpers/ColorHelper.js +215 -0
  49. package/build/Helpers/FactoryHelper.d.ts +14 -0
  50. package/build/Helpers/FactoryHelper.js +20 -0
  51. package/build/Logger/Logger.d.ts +68 -0
  52. package/build/Logger/Logger.js +105 -0
  53. package/build/Logger/VanillaLogger.d.ts +60 -0
  54. package/build/Logger/VanillaLogger.js +86 -0
  55. package/build/Providers/LoggerProvider.d.ts +12 -0
  56. package/{src → build}/Providers/LoggerProvider.js +5 -12
  57. package/build/index.d.ts +18 -0
  58. package/build/index.js +18 -0
  59. package/package.json +81 -59
  60. package/src/Drivers/ConsoleDriver.js +0 -40
  61. package/src/Drivers/DiscordDriver.js +0 -43
  62. package/src/Drivers/Driver.js +0 -134
  63. package/src/Drivers/FileDriver.js +0 -47
  64. package/src/Drivers/NullDriver.js +0 -33
  65. package/src/Drivers/SlackDriver.js +0 -40
  66. package/src/Drivers/StackDriver.js +0 -45
  67. package/src/Drivers/TelegramDriver.js +0 -46
  68. package/src/Exceptions/DriverExistException.js +0 -31
  69. package/src/Exceptions/FormatterExistException.js +0 -32
  70. package/src/Exceptions/NotFoundDriverException.js +0 -31
  71. package/src/Exceptions/NotFoundFormatterException.js +0 -31
  72. package/src/Exceptions/NotImplementedConfigException.js +0 -37
  73. package/src/Factories/DriverFactory.js +0 -128
  74. package/src/Factories/FormatterFactory.js +0 -77
  75. package/src/Formatters/CliFormatter.js +0 -24
  76. package/src/Formatters/Formatter.js +0 -266
  77. package/src/Formatters/JsonFormatter.js +0 -37
  78. package/src/Formatters/MessageFormatter.js +0 -26
  79. package/src/Formatters/RequestFormatter.js +0 -64
  80. package/src/Formatters/SimpleFormatter.js +0 -27
  81. package/src/Helpers/ColorHelper.js +0 -322
  82. package/src/Helpers/FactoryHelper.js +0 -31
  83. package/src/Helpers/VanillaLogger.js +0 -134
  84. package/src/index.d.ts +0 -797
  85. package/src/index.js +0 -180
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class ConsoleDriver extends Driver {
11
+ transport(level: string, message: any): any;
12
+ }
@@ -0,0 +1,19 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export class ConsoleDriver extends Driver {
11
+ transport(level, message) {
12
+ if (!this.couldBeTransported(level)) {
13
+ return;
14
+ }
15
+ const formatted = this.format(level, message);
16
+ const streamType = this.getStreamTypeFor(level);
17
+ return process[streamType].write(`${formatted}\n`);
18
+ }
19
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class DiscordDriver extends Driver {
11
+ transport(level: string, message: any): Promise<any>;
12
+ }
@@ -0,0 +1,22 @@
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 { HttpClient } from '@athenna/common';
10
+ import { Driver } from '#src/Drivers/Driver';
11
+ export class DiscordDriver extends Driver {
12
+ async transport(level, message) {
13
+ if (!this.couldBeTransported(level)) {
14
+ return;
15
+ }
16
+ const formatted = this.format(level, message, true);
17
+ return HttpClient.builder(true).post(this.configs.url, {
18
+ username: this.configs.username,
19
+ content: formatted,
20
+ });
21
+ }
22
+ }
@@ -0,0 +1,52 @@
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
+ export declare abstract class Driver {
10
+ /**
11
+ * Holds the configuration object itself.
12
+ */
13
+ configs: any;
14
+ /**
15
+ * Holds the configuration object of driver,
16
+ */
17
+ driverConfig: any;
18
+ /**
19
+ * Holds the formatter string value.
20
+ */
21
+ formatter: string;
22
+ /**
23
+ * Holds the configuration object of formatter.
24
+ */
25
+ formatterConfig: any;
26
+ /**
27
+ * The max log level that this driver can transport.
28
+ */
29
+ level: string;
30
+ /**
31
+ * The log level order to check if log could
32
+ * be transported or not.
33
+ */
34
+ levelOrder: string[];
35
+ constructor(configs?: any);
36
+ /**
37
+ * Transport the log.
38
+ */
39
+ abstract transport(level: string, message: any): any;
40
+ /**
41
+ * Check if message could be transported.
42
+ */
43
+ couldBeTransported(level: string): boolean;
44
+ /**
45
+ * Call formatter factory to format the message.
46
+ */
47
+ format(level: string, message: any, clean?: boolean): string;
48
+ /**
49
+ * Get the stream type for level.
50
+ */
51
+ getStreamTypeFor(level: string): string;
52
+ }
@@ -0,0 +1,85 @@
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 { Json } from '@athenna/common';
10
+ import { FormatterFactory } from '#src/Factories/FormatterFactory';
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
+ constructor(configs = {}) {
46
+ this.configs = configs;
47
+ const json = Json.copy(configs);
48
+ delete json.formatter;
49
+ delete json.formatterConfig;
50
+ this.driverConfig = json;
51
+ this.level = json.level || 'info';
52
+ this.formatter = configs.formatter || 'none';
53
+ this.formatterConfig = configs.formatterConfig || {};
54
+ }
55
+ /**
56
+ * Check if message could be transported.
57
+ */
58
+ couldBeTransported(level) {
59
+ const levelIndex = this.levelOrder.indexOf(level);
60
+ const maxLevelIndex = this.levelOrder.indexOf(this.level);
61
+ return levelIndex >= maxLevelIndex;
62
+ }
63
+ /**
64
+ * Call formatter factory to format the message.
65
+ */
66
+ format(level, message, clean = false) {
67
+ const formatterConfig = { level, clean, ...this.formatterConfig };
68
+ return FormatterFactory.fabricate(this.formatter)
69
+ .config(formatterConfig)
70
+ .format(message);
71
+ }
72
+ /**
73
+ * Get the stream type for level.
74
+ */
75
+ getStreamTypeFor(level) {
76
+ if (this.driverConfig.streamType) {
77
+ return this.driverConfig.streamType;
78
+ }
79
+ let streamType = 'stdout';
80
+ if (level === 'error' || level === 'fatal') {
81
+ streamType = 'stderr';
82
+ }
83
+ return streamType;
84
+ }
85
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class FileDriver extends Driver {
11
+ transport(level: string, message: any): Promise<any>;
12
+ }
@@ -0,0 +1,24 @@
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 { File } from '@athenna/common';
10
+ import { Driver } from '#src/Drivers/Driver';
11
+ export class FileDriver extends Driver {
12
+ async transport(level, message) {
13
+ if (!this.couldBeTransported(level)) {
14
+ return;
15
+ }
16
+ const filePath = this.driverConfig.filePath;
17
+ const formatted = this.format(level, message, true);
18
+ const buffer = Buffer.from(`${formatted}\n`, 'utf-8');
19
+ if (await File.exists(filePath)) {
20
+ return new File(filePath).append(buffer);
21
+ }
22
+ return new File(filePath, buffer).load();
23
+ }
24
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class NullDriver extends Driver {
11
+ transport(): any;
12
+ }
@@ -0,0 +1,14 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export class NullDriver extends Driver {
11
+ transport() {
12
+ return null;
13
+ }
14
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class SlackDriver extends Driver {
11
+ transport(level: string, message: any): Promise<any>;
12
+ }
@@ -0,0 +1,19 @@
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 { HttpClient } from '@athenna/common';
10
+ import { Driver } from '#src/Drivers/Driver';
11
+ export class SlackDriver extends Driver {
12
+ async transport(level, message) {
13
+ if (!this.couldBeTransported(level)) {
14
+ return;
15
+ }
16
+ const formatted = this.format(level, message, true);
17
+ return HttpClient.builder(true).post(this.configs.url, { text: formatted });
18
+ }
19
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class StackDriver extends Driver {
11
+ transport(level: string, message: any): Promise<any>;
12
+ }
@@ -0,0 +1,19 @@
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 { Json } from '@athenna/common';
10
+ import { Driver } from '#src/Drivers/Driver';
11
+ import { DriverFactory } from '#src/Factories/DriverFactory';
12
+ export class StackDriver extends Driver {
13
+ transport(level, message) {
14
+ const configs = Json.copy(this.configs);
15
+ delete configs.driver;
16
+ delete configs.channels;
17
+ return Promise.all(this.driverConfig.channels.map(c => DriverFactory.fabricate(c, configs).transport(level, message)));
18
+ }
19
+ }
@@ -0,0 +1,12 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class TelegramDriver extends Driver {
11
+ transport(level: string, message: any): Promise<any>;
12
+ }
@@ -0,0 +1,21 @@
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 { Telegraf } from 'telegraf';
10
+ import { Driver } from '#src/Drivers/Driver';
11
+ export class TelegramDriver extends Driver {
12
+ async transport(level, message) {
13
+ if (!this.couldBeTransported(level)) {
14
+ return;
15
+ }
16
+ const formatted = this.format(level, message, true);
17
+ return new Telegraf(this.driverConfig.token).telegram.sendMessage(this.driverConfig.chatId, formatted, {
18
+ parse_mode: this.driverConfig.parseMode,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,12 @@
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 { Exception } from '@athenna/common';
10
+ export declare class DriverExistException extends Exception {
11
+ constructor(driverName: string);
12
+ }
@@ -0,0 +1,21 @@
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 { Exception } from '@athenna/common';
10
+ import { DriverFactory } from '#src/Factories/DriverFactory';
11
+ export class DriverExistException extends Exception {
12
+ constructor(driverName) {
13
+ const availableDrivers = DriverFactory.availableDrivers().join(', ');
14
+ super({
15
+ status: 500,
16
+ code: 'E_EXIST_DRIVER',
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.`,
19
+ });
20
+ }
21
+ }
@@ -6,12 +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
-
10
- import { Facade } from '@athenna/ioc'
11
-
12
- /**
13
- * Log facade.
14
- *
15
- * @type {typeof Facade & import('#src/index').Logger}
16
- */
17
- export const Log = Facade.createFor('Athenna/Core/Logger')
9
+ import { Exception } from '@athenna/common';
10
+ export declare class FormatterExistException extends Exception {
11
+ constructor(formatterName: string);
12
+ }
@@ -0,0 +1,21 @@
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 { Exception } from '@athenna/common';
10
+ import { FormatterFactory } from '#src/Factories/FormatterFactory';
11
+ export class FormatterExistException extends Exception {
12
+ constructor(formatterName) {
13
+ const availableFormatters = FormatterFactory.availableFormatters().join(', ');
14
+ super({
15
+ status: 500,
16
+ code: 'E_EXIST_FORMATTER',
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.`,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,12 @@
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 { Exception } from '@athenna/common';
10
+ export declare class NotFoundDriverException extends Exception {
11
+ constructor(driverName: string);
12
+ }
@@ -0,0 +1,21 @@
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 { Exception, Path } from '@athenna/common';
10
+ import { DriverFactory } from '#src/Factories/DriverFactory';
11
+ export class NotFoundDriverException extends Exception {
12
+ constructor(driverName) {
13
+ const availableDrivers = DriverFactory.availableDrivers().join(', ');
14
+ super({
15
+ status: 500,
16
+ code: 'E_NOT_FOUND',
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.`,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,12 @@
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 { Exception } from '@athenna/common';
10
+ export declare class NotFoundFormatterException extends Exception {
11
+ constructor(formatterName: string);
12
+ }
@@ -0,0 +1,21 @@
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 { Exception } from '@athenna/common';
10
+ import { FormatterFactory } from '#src/Factories/FormatterFactory';
11
+ export class NotFoundFormatterException extends Exception {
12
+ constructor(formatterName) {
13
+ const availableDrivers = FormatterFactory.availableFormatters().join(', ');
14
+ super({
15
+ status: 500,
16
+ code: 'E_NOT_FOUND',
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.`,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,12 @@
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 { Exception } from '@athenna/common';
10
+ export declare class NotImplementedConfigException extends Exception {
11
+ constructor(channelName: string, channels?: any[]);
12
+ }
@@ -0,0 +1,28 @@
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 { Path, Exception } from '@athenna/common';
10
+ export class NotImplementedConfigException extends Exception {
11
+ constructor(channelName, channels) {
12
+ let help = '';
13
+ if (channels && channels.length) {
14
+ const availableConfigs = Object.keys(channels).join(', ');
15
+ help += `Available configurations are: ${availableConfigs}.`;
16
+ }
17
+ else {
18
+ help += `The "Config.get('logging.channels')" is empty, maybe your configuration files are not loaded?`;
19
+ }
20
+ help += ` Create your configuration inside channels object to use it. Or load your configuration files using "Config.safeLoad(Path.config('logging.${Path.ext()}'))`;
21
+ super({
22
+ status: 500,
23
+ code: 'E_NOT_IMPLEMENTED_CONFIG_ERROR',
24
+ message: `Channel ${channelName} is not configured inside logging.channels object from config/logging.${Path.ext()} file.`,
25
+ help,
26
+ });
27
+ }
28
+ }
@@ -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").FacadeType<Logger>;
@@ -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 { Facade } from '@athenna/ioc';
10
+ export const Log = Facade.createFor('Athenna/Core/Logger');
@@ -0,0 +1,39 @@
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 { Driver } from '#src/Drivers/Driver';
10
+ export declare class DriverFactory {
11
+ /**
12
+ * Drivers of DriverFactory.
13
+ */
14
+ static drivers: Map<string, {
15
+ Driver: any;
16
+ }>;
17
+ /**
18
+ * Return an array with all available drivers.
19
+ */
20
+ static availableDrivers(): any[];
21
+ /**
22
+ * Fabricate a new instance of a driver based on
23
+ * channel configurations.
24
+ */
25
+ static fabricate(channelName: string, configs?: any): Driver;
26
+ /**
27
+ * Fabricate a new instance of a driver with vanilla
28
+ * configurations.
29
+ */
30
+ static fabricateVanilla(configs?: any): Driver;
31
+ /**
32
+ * Creates a new driver implementation.
33
+ */
34
+ static createDriver(name: string, driver: typeof Driver): void;
35
+ /**
36
+ * Get all the configuration of a channel.
37
+ */
38
+ static getChannelConfig(channelName: string): any;
39
+ }