@athenna/logger 3.0.9 → 3.1.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/build/Drivers/ConsoleDriver.d.ts +12 -0
- package/build/Drivers/ConsoleDriver.js +19 -0
- package/build/Drivers/DiscordDriver.d.ts +12 -0
- package/build/Drivers/DiscordDriver.js +22 -0
- package/build/Drivers/Driver.d.ts +52 -0
- package/build/Drivers/Driver.js +85 -0
- package/build/Drivers/FileDriver.d.ts +12 -0
- package/build/Drivers/FileDriver.js +24 -0
- package/build/Drivers/NullDriver.d.ts +12 -0
- package/build/Drivers/NullDriver.js +14 -0
- package/build/Drivers/SlackDriver.d.ts +12 -0
- package/build/Drivers/SlackDriver.js +19 -0
- package/build/Drivers/StackDriver.d.ts +12 -0
- package/build/Drivers/StackDriver.js +19 -0
- package/build/Drivers/TelegramDriver.d.ts +12 -0
- package/build/Drivers/TelegramDriver.js +21 -0
- package/build/Exceptions/DriverExistException.d.ts +12 -0
- package/build/Exceptions/DriverExistException.js +21 -0
- package/{src/Facades/Log.js → build/Exceptions/FormatterExistException.d.ts} +4 -9
- package/build/Exceptions/FormatterExistException.js +21 -0
- package/build/Exceptions/NotFoundDriverException.d.ts +12 -0
- package/build/Exceptions/NotFoundDriverException.js +21 -0
- package/build/Exceptions/NotFoundFormatterException.d.ts +12 -0
- package/build/Exceptions/NotFoundFormatterException.js +21 -0
- package/build/Exceptions/NotImplementedConfigException.d.ts +12 -0
- package/build/Exceptions/NotImplementedConfigException.js +28 -0
- package/build/Facades/Log.d.ts +10 -0
- package/build/Facades/Log.js +10 -0
- package/build/Factories/DriverFactory.d.ts +39 -0
- package/build/Factories/DriverFactory.js +93 -0
- package/build/Factories/FormatterFactory.d.ts +29 -0
- package/build/Factories/FormatterFactory.js +57 -0
- package/build/Formatters/CliFormatter.d.ts +12 -0
- package/build/Formatters/CliFormatter.js +15 -0
- package/build/Formatters/Formatter.d.ts +85 -0
- package/build/Formatters/Formatter.js +176 -0
- package/build/Formatters/JsonFormatter.d.ts +12 -0
- package/build/Formatters/JsonFormatter.js +26 -0
- package/build/Formatters/MessageFormatter.d.ts +12 -0
- package/build/Formatters/MessageFormatter.js +14 -0
- package/build/Formatters/NoneFormatter.d.ts +12 -0
- package/{src → build}/Formatters/NoneFormatter.js +4 -12
- package/build/Formatters/RequestFormatter.d.ts +12 -0
- package/build/Formatters/RequestFormatter.js +48 -0
- package/build/Formatters/SimpleFormatter.d.ts +12 -0
- package/build/Formatters/SimpleFormatter.js +18 -0
- package/build/Helpers/FactoryHelper.d.ts +14 -0
- package/build/Helpers/FactoryHelper.js +20 -0
- package/build/Logger/Logger.d.ts +68 -0
- package/build/Logger/Logger.js +105 -0
- package/build/Logger/VanillaLogger.d.ts +65 -0
- package/build/Logger/VanillaLogger.js +93 -0
- package/build/Providers/LoggerProvider.d.ts +12 -0
- package/{src → build}/Providers/LoggerProvider.js +5 -12
- package/build/index.d.ts +17 -0
- package/build/index.js +17 -0
- package/package.json +82 -61
- package/src/Drivers/ConsoleDriver.js +0 -40
- package/src/Drivers/DiscordDriver.js +0 -43
- package/src/Drivers/Driver.js +0 -134
- package/src/Drivers/FileDriver.js +0 -47
- package/src/Drivers/NullDriver.js +0 -33
- package/src/Drivers/SlackDriver.js +0 -40
- package/src/Drivers/StackDriver.js +0 -45
- package/src/Drivers/TelegramDriver.js +0 -46
- package/src/Exceptions/DriverExistException.js +0 -31
- package/src/Exceptions/FormatterExistException.js +0 -32
- package/src/Exceptions/NotFoundDriverException.js +0 -31
- package/src/Exceptions/NotFoundFormatterException.js +0 -31
- package/src/Exceptions/NotImplementedConfigException.js +0 -37
- package/src/Factories/DriverFactory.js +0 -128
- package/src/Factories/FormatterFactory.js +0 -77
- package/src/Formatters/CliFormatter.js +0 -24
- package/src/Formatters/Formatter.js +0 -266
- package/src/Formatters/JsonFormatter.js +0 -37
- package/src/Formatters/MessageFormatter.js +0 -26
- package/src/Formatters/RequestFormatter.js +0 -64
- package/src/Formatters/SimpleFormatter.js +0 -27
- package/src/Helpers/ColorHelper.js +0 -322
- package/src/Helpers/FactoryHelper.js +0 -31
- package/src/Helpers/VanillaLogger.js +0 -134
- package/src/index.d.ts +0 -797
- package/src/index.js +0 -180
package/src/index.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
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 { ColorHelper } from '#src/index'
|
|
11
|
-
import { VanillaLogger } from '#src/Helpers/VanillaLogger'
|
|
12
|
-
import { DriverFactory } from '#src/Factories/DriverFactory'
|
|
13
|
-
|
|
14
|
-
export * from './Facades/Log.js'
|
|
15
|
-
|
|
16
|
-
export * from './Helpers/ColorHelper.js'
|
|
17
|
-
export * from './Helpers/VanillaLogger.js'
|
|
18
|
-
export * from './Helpers/FactoryHelper.js'
|
|
19
|
-
|
|
20
|
-
export * from './Drivers/Driver.js'
|
|
21
|
-
export * from './Formatters/Formatter.js'
|
|
22
|
-
|
|
23
|
-
export * from './Factories/DriverFactory.js'
|
|
24
|
-
export * from './Factories/FormatterFactory.js'
|
|
25
|
-
|
|
26
|
-
export class Logger {
|
|
27
|
-
/**
|
|
28
|
-
* The driver responsible for transporting the logs.
|
|
29
|
-
*
|
|
30
|
-
* @type {any[]}
|
|
31
|
-
*/
|
|
32
|
-
#drivers = []
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Runtime configurations to be used inside the Drivers and Formatters.
|
|
36
|
-
*
|
|
37
|
-
* @type {any}
|
|
38
|
-
*/
|
|
39
|
-
#runtimeConfigs = {}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new instance of Logger.
|
|
43
|
-
*
|
|
44
|
-
* @return {Logger}
|
|
45
|
-
*/
|
|
46
|
-
constructor() {
|
|
47
|
-
if (!Config.exists(`logging.channels.${Config.get('logging.default')}`)) {
|
|
48
|
-
return this
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.#drivers.push(DriverFactory.fabricate('default', this.#runtimeConfigs))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Set runtime configurations for drivers and
|
|
56
|
-
* formatters.
|
|
57
|
-
*
|
|
58
|
-
* @param {any} runtimeConfigs
|
|
59
|
-
* @return {Logger}
|
|
60
|
-
*/
|
|
61
|
-
config(runtimeConfigs) {
|
|
62
|
-
this.#runtimeConfigs = runtimeConfigs
|
|
63
|
-
|
|
64
|
-
return this
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Change the log channel.
|
|
69
|
-
*
|
|
70
|
-
* @param {string} channels
|
|
71
|
-
* @return {Logger}
|
|
72
|
-
*/
|
|
73
|
-
channel(...channels) {
|
|
74
|
-
this.#drivers = []
|
|
75
|
-
|
|
76
|
-
channels.forEach(c => {
|
|
77
|
-
this.#drivers.push(DriverFactory.fabricate(c, this.#runtimeConfigs))
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
return this
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Call drivers to transport the log.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} level
|
|
87
|
-
* @param {string} args
|
|
88
|
-
* @return {any | Promise<any>}
|
|
89
|
-
*/
|
|
90
|
-
#log(level, ...args) {
|
|
91
|
-
const message = ColorHelper.applyLogEngine(...args)
|
|
92
|
-
|
|
93
|
-
const promises = this.#drivers.map(d => d.transport(level, message))
|
|
94
|
-
|
|
95
|
-
return Promise.all(promises)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Creates a log of type trace in channel.
|
|
100
|
-
*
|
|
101
|
-
* @param {string|any} args
|
|
102
|
-
* @return {any | Promise<any>}
|
|
103
|
-
*/
|
|
104
|
-
trace(...args) {
|
|
105
|
-
return this.#log('trace', ...args)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Creates a log of type debug in channel.
|
|
110
|
-
*
|
|
111
|
-
* @param {string|any} args
|
|
112
|
-
* @return {any | Promise<any>}
|
|
113
|
-
*/
|
|
114
|
-
debug(...args) {
|
|
115
|
-
return this.#log('debug', ...args)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Creates a log of type info in channel.
|
|
120
|
-
*
|
|
121
|
-
* @param {string|any} args
|
|
122
|
-
* @return {any | Promise<any>}
|
|
123
|
-
*/
|
|
124
|
-
info(...args) {
|
|
125
|
-
return this.#log('info', ...args)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Creates a log of type success in channel.
|
|
130
|
-
*
|
|
131
|
-
* @param {string|any} args
|
|
132
|
-
* @return {any | Promise<any>}
|
|
133
|
-
*/
|
|
134
|
-
success(...args) {
|
|
135
|
-
return this.#log('success', ...args)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Creates a log of type warn in channel.
|
|
140
|
-
*
|
|
141
|
-
* @param {string|any} args
|
|
142
|
-
* @return {any | Promise<any>}
|
|
143
|
-
*/
|
|
144
|
-
warn(...args) {
|
|
145
|
-
return this.#log('warn', ...args)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Creates a log of type error in channel.
|
|
150
|
-
*
|
|
151
|
-
* @param {string|any} args
|
|
152
|
-
* @return {any | Promise<any>}
|
|
153
|
-
*/
|
|
154
|
-
error(...args) {
|
|
155
|
-
return this.#log('error', ...args)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Creates a log of type fatal in channel.
|
|
160
|
-
*
|
|
161
|
-
* @param {string|any} args
|
|
162
|
-
* @return {any | Promise<any>}
|
|
163
|
-
*/
|
|
164
|
-
fatal(...args) {
|
|
165
|
-
return this.#log('fatal', ...args)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
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.
|
|
173
|
-
*
|
|
174
|
-
* @param {any} [configs]
|
|
175
|
-
* @return {VanillaLogger}
|
|
176
|
-
*/
|
|
177
|
-
static getVanillaLogger(configs = {}) {
|
|
178
|
-
return new VanillaLogger(configs)
|
|
179
|
-
}
|
|
180
|
-
}
|