@athenna/logger 3.0.7 → 3.0.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/logger",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
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>",
@@ -20,6 +20,7 @@ import { TelegramDriver } from '#src/Drivers/TelegramDriver'
20
20
  import { DriverExistException } from '#src/Exceptions/DriverExistException'
21
21
  import { NotFoundDriverException } from '#src/Exceptions/NotFoundDriverException'
22
22
  import { NotImplementedConfigException } from '#src/Exceptions/NotImplementedConfigException'
23
+ import { Options } from '@athenna/common'
23
24
 
24
25
  export class DriverFactory {
25
26
  /**
@@ -70,17 +71,21 @@ export class DriverFactory {
70
71
  }
71
72
 
72
73
  /**
73
- * Fabricate a new instance of a driver without
74
+ * Fabricate a new instance of a driver with vanilla
74
75
  * configurations.
75
76
  *
76
- * @param {string} driverName
77
- * @param {any} runtimeConfig
77
+ * @param {any} configs
78
78
  * @return {any}
79
79
  */
80
- static fabricateOnly(driverName, runtimeConfig = {}) {
81
- const { Driver } = this.#drivers.get(driverName)
80
+ static fabricateVanilla(configs = {}) {
81
+ configs = Options.create(configs, {
82
+ driver: 'console',
83
+ formatter: 'none',
84
+ })
85
+
86
+ const { Driver } = this.#drivers.get(configs.driver)
82
87
 
83
- return new Driver(runtimeConfig)
88
+ return new Driver(configs)
84
89
  }
85
90
 
86
91
  /**
@@ -10,7 +10,7 @@
10
10
  import { ColorHelper } from '#src/index'
11
11
  import { DriverFactory } from '#src/Factories/DriverFactory'
12
12
 
13
- export class ConsoleLogger {
13
+ export class VanillaLogger {
14
14
  /**
15
15
  * The driver responsible for transporting the logs.
16
16
  *
@@ -21,18 +21,18 @@ export class ConsoleLogger {
21
21
  /**
22
22
  * Creates a new instance of ConsoleLogger.
23
23
  *
24
- * @param {any} [runtimeConfigs]
25
- * @return {ConsoleLogger}
24
+ * @param {any} [configs]
25
+ * @return {VanillaLogger}
26
26
  */
27
- constructor(runtimeConfigs) {
28
- this.#drivers.push(DriverFactory.fabricateOnly('console', runtimeConfigs))
27
+ constructor(configs) {
28
+ this.#drivers.push(DriverFactory.fabricateVanilla(configs))
29
29
  }
30
30
 
31
31
  /**
32
32
  * Set runtime configurations for drivers and
33
33
  * formatters.
34
34
  *
35
- * @return {ConsoleLogger}
35
+ * @return {VanillaLogger}
36
36
  */
37
37
  config() {
38
38
  return this
@@ -41,7 +41,7 @@ export class ConsoleLogger {
41
41
  /**
42
42
  * Change the log channel.
43
43
  *
44
- * @return {ConsoleLogger}
44
+ * @return {VanillaLogger}
45
45
  */
46
46
  channel() {
47
47
  return this
package/src/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import { Facade } from '@athenna/ioc'
11
+ import { Options } from '@athenna/common'
11
12
 
12
13
  export const Log: typeof Facade & Logger
13
14
 
@@ -465,14 +466,13 @@ export class DriverFactory {
465
466
  static fabricate(channelName: string, runtimeConfig?: any): any
466
467
 
467
468
  /**
468
- * Fabricate a new instance of a driver without
469
+ * Fabricate a new instance of a driver with vanilla
469
470
  * configurations.
470
471
  *
471
- * @param {string} driverName
472
- * @param {any} runtimeConfig
472
+ * @param {any} configs
473
473
  * @return {any}
474
474
  */
475
- static fabricateOnly(driverName: string, runtimeConfig?: any): any
475
+ static fabricateVanilla(configs?: any): any
476
476
 
477
477
  /**
478
478
  * Creates a new driver implementation.
@@ -523,7 +523,24 @@ export class FormatterFactory {
523
523
  static createFormatter(name: string, formatter: () => any): void
524
524
  }
525
525
 
526
- export class ConsoleLogger {
526
+ export class VanillaLogger {
527
+ /**
528
+ * Set runtime configurations for drivers and
529
+ * formatters.
530
+ *
531
+ * @param {any} runtimeConfig
532
+ * @return {VanillaLogger}
533
+ */
534
+ config(runtimeConfig: any): VanillaLogger
535
+
536
+ /**
537
+ * Change the log channel.
538
+ *
539
+ * @param {string[]} channels
540
+ * @return {VanillaLogger}
541
+ */
542
+ channel(...channels: string[]): VanillaLogger
543
+
527
544
  /**
528
545
  * Creates a log of type trace in channel.
529
546
  *
@@ -619,6 +636,22 @@ export class ConsoleLogger {
619
636
  * @return {any | Promise<any>}
620
637
  */
621
638
  error(...args: string[] | any[]): any | Promise<any>
639
+
640
+ /**
641
+ * Creates a log of type fatal in channel.
642
+ *
643
+ * @param {string|any} message
644
+ * @return {any | Promise<any>}
645
+ */
646
+ fatal(message: string | any): any | Promise<any>
647
+
648
+ /**
649
+ * Creates a log of type fatal in channel.
650
+ *
651
+ * @param {string[]|any[]} args
652
+ * @return {any | Promise<any>}
653
+ */
654
+ fatal(...args: string[] | any[]): any | Promise<any>
622
655
  }
623
656
 
624
657
  export class Logger {
@@ -736,18 +769,29 @@ export class Logger {
736
769
  error(...args: string[] | any[]): any | Promise<any>
737
770
 
738
771
  /**
739
- * Get a new instance of the ConsoleLogger.
772
+ * Creates a log of type fatal in channel.
740
773
  *
741
- * @param {any} [runtimeConfigs]
742
- * @return {ConsoleLogger}
774
+ * @param {string|any} message
775
+ * @return {any | Promise<any>}
776
+ */
777
+ fatal(message: string | any): any | Promise<any>
778
+
779
+ /**
780
+ * Creates a log of type fatal in channel.
781
+ *
782
+ * @param {string[]|any[]} args
783
+ * @return {any | Promise<any>}
743
784
  */
744
- getConsoleLogger(runtimeConfigs?: any): ConsoleLogger
785
+ fatal(...args: string[] | any[]): any | Promise<any>
745
786
 
746
787
  /**
747
- * Get a new instance of the ConsoleLogger.
788
+ * Get a new instance of any log driver
789
+ * with vanilla configurations. By default,
790
+ * vanilla logger will use the "console" driver
791
+ * and "none" formatter.
748
792
  *
749
- * @param {any} [runtimeConfigs]
750
- * @return {ConsoleLogger}
793
+ * @param {any} [configs]
794
+ * @return {VanillaLogger}
751
795
  */
752
- static getConsoleLogger(runtimeConfigs?: any): ConsoleLogger
796
+ static getVanillaLogger(configs?: any): VanillaLogger
753
797
  }
package/src/index.js CHANGED
@@ -8,13 +8,13 @@
8
8
  */
9
9
 
10
10
  import { ColorHelper } from '#src/index'
11
- import { ConsoleLogger } from '#src/Helpers/ConsoleLogger'
11
+ import { VanillaLogger } from '#src/Helpers/VanillaLogger'
12
12
  import { DriverFactory } from '#src/Factories/DriverFactory'
13
13
 
14
14
  export * from './Facades/Log.js'
15
15
 
16
16
  export * from './Helpers/ColorHelper.js'
17
- export * from './Helpers/ConsoleLogger.js'
17
+ export * from './Helpers/VanillaLogger.js'
18
18
  export * from './Helpers/FactoryHelper.js'
19
19
 
20
20
  export * from './Drivers/Driver.js'
@@ -166,22 +166,15 @@ export class Logger {
166
166
  }
167
167
 
168
168
  /**
169
- * Get a new instance of the ConsoleLogger.
169
+ * Get a new instance of any log driver
170
+ * with vanilla configurations. By default,
171
+ * vanilla logger will use the "console" driver
172
+ * and "none" formatter.
170
173
  *
171
- * @param {any} [runtimeConfigs]
172
- * @return {ConsoleLogger}
174
+ * @param {any} [configs]
175
+ * @return {VanillaLogger}
173
176
  */
174
- getConsoleLogger(runtimeConfigs) {
175
- return Logger.getConsoleLogger(runtimeConfigs)
176
- }
177
-
178
- /**
179
- * Get a new instance of the ConsoleLogger.
180
- *
181
- * @param {any} [runtimeConfigs]
182
- * @return {ConsoleLogger}
183
- */
184
- static getConsoleLogger(runtimeConfigs) {
185
- return new ConsoleLogger(runtimeConfigs)
177
+ static getVanillaLogger(configs = {}) {
178
+ return new VanillaLogger(configs)
186
179
  }
187
180
  }