@athenna/logger 3.0.7 → 3.0.8
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
|
@@ -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
|
|
74
|
+
* Fabricate a new instance of a driver with vanilla
|
|
74
75
|
* configurations.
|
|
75
76
|
*
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {any} runtimeConfig
|
|
77
|
+
* @param {any} configs
|
|
78
78
|
* @return {any}
|
|
79
79
|
*/
|
|
80
|
-
static
|
|
81
|
-
|
|
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(
|
|
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
|
|
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} [
|
|
25
|
-
* @return {
|
|
24
|
+
* @param {any} [configs]
|
|
25
|
+
* @return {VanillaLogger}
|
|
26
26
|
*/
|
|
27
|
-
constructor(
|
|
28
|
-
this.#drivers.push(DriverFactory.
|
|
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 {
|
|
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 {
|
|
44
|
+
* @return {VanillaLogger}
|
|
45
45
|
*/
|
|
46
46
|
channel() {
|
|
47
47
|
return this
|
package/src/index.d.ts
CHANGED
|
@@ -523,7 +523,24 @@ export class FormatterFactory {
|
|
|
523
523
|
static createFormatter(name: string, formatter: () => any): void
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
-
export class
|
|
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
|
-
*
|
|
772
|
+
* Creates a log of type fatal in channel.
|
|
740
773
|
*
|
|
741
|
-
* @param {any}
|
|
742
|
-
* @return {
|
|
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
|
-
|
|
785
|
+
fatal(...args: string[] | any[]): any | Promise<any>
|
|
745
786
|
|
|
746
787
|
/**
|
|
747
|
-
* Get a new instance of
|
|
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} [
|
|
750
|
-
* @return {
|
|
793
|
+
* @param {any} [configs]
|
|
794
|
+
* @return {VanillaLogger}
|
|
751
795
|
*/
|
|
752
|
-
static
|
|
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 {
|
|
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/
|
|
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
|
|
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} [
|
|
172
|
-
* @return {
|
|
174
|
+
* @param {any} [configs]
|
|
175
|
+
* @return {VanillaLogger}
|
|
173
176
|
*/
|
|
174
|
-
|
|
175
|
-
return
|
|
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
|
}
|