ntlogger 2.2.3 → 2.3.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.
- package/lib/logger.js +12 -2
- package/package.json +12 -3
package/lib/logger.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
const winston = require('winston');
|
|
14
14
|
const crypto = require('crypto');
|
|
15
15
|
|
|
16
|
+
const { initPlugins, compilePluginComponents} = require('../plugins/index.js');
|
|
17
|
+
|
|
16
18
|
// Define a map to hold the logger instances by their location
|
|
17
19
|
const loggerInstances = new Map();
|
|
18
20
|
|
|
@@ -111,7 +113,7 @@ const fileFormatter = (config) => winston.format.combine(
|
|
|
111
113
|
}),
|
|
112
114
|
);
|
|
113
115
|
|
|
114
|
-
const createLoggerInstance = (location = "Unknown", config = {}) => {
|
|
116
|
+
const createLoggerInstance = (location = "Unknown", config = {}, transports) => {
|
|
115
117
|
// Configuration options
|
|
116
118
|
const {
|
|
117
119
|
level = 'info',
|
|
@@ -150,6 +152,8 @@ const createLoggerInstance = (location = "Unknown", config = {}) => {
|
|
|
150
152
|
new winston.transports.File({ filename: `${path}/combined.log`, format: fileFormat, maxsize: maxSize, maxFiles: maxFiles }),
|
|
151
153
|
);
|
|
152
154
|
}
|
|
155
|
+
if (transports) {logTransport = logTransport.concat
|
|
156
|
+
(transports);}
|
|
153
157
|
|
|
154
158
|
// Create a new logger instance
|
|
155
159
|
const logger = winston.createLogger({
|
|
@@ -202,8 +206,14 @@ const logger = (location = "Unknown", config = {}) => {
|
|
|
202
206
|
return logger;
|
|
203
207
|
}
|
|
204
208
|
|
|
209
|
+
let transports = null;
|
|
210
|
+
// Initialize plugins if they are provided in the configuration
|
|
211
|
+
if (config.plugins) {
|
|
212
|
+
transports = initPlugins(config.plugins)
|
|
213
|
+
}
|
|
214
|
+
|
|
205
215
|
// If not, create a new logger instance for the location
|
|
206
|
-
return createLoggerInstance(location, config);
|
|
216
|
+
return createLoggerInstance(location, config, transports);
|
|
207
217
|
};
|
|
208
218
|
|
|
209
219
|
// Export a function to create or return the existing logger instance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ntlogger",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/NightSquawk/NightTimeLogger.git"
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"custom logger",
|
|
17
17
|
"logging",
|
|
18
18
|
"log management",
|
|
19
|
-
"logging utility"
|
|
19
|
+
"logging utility",
|
|
20
|
+
"sentry compatible",
|
|
21
|
+
"mysql compatible"
|
|
20
22
|
],
|
|
21
23
|
"files": [
|
|
22
24
|
"index.js",
|
|
@@ -24,6 +26,13 @@
|
|
|
24
26
|
],
|
|
25
27
|
"license": "GPL-3.0",
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"
|
|
29
|
+
"@sentry/node": "^8.17.0",
|
|
30
|
+
"mysql2": "^3.10.2",
|
|
31
|
+
"winston": "^3.13.1",
|
|
32
|
+
"winston-transport": "^4.7.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@sentry/profiling-node": "^8.17.0",
|
|
36
|
+
"dotenv": "^16.4.5"
|
|
28
37
|
}
|
|
29
38
|
}
|