ntlogger 2.6.2 → 2.7.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/index.js +18 -4
- package/package.json +1 -1
- package/plugins/index.js +19 -2
package/index.js
CHANGED
|
@@ -5,14 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* TODO: [
|
|
9
|
-
* TODO: [
|
|
10
|
-
* TODO: [
|
|
11
|
-
* TODO: [
|
|
8
|
+
* TODO: [FEATURE] Generic Webhook Plugin for sending logs to any webhook
|
|
9
|
+
* TODO: [FEATURE] Email Plugin for sending logs to an email address
|
|
10
|
+
* TODO: [FEATURE] SMS Mail ID Plugin for sending logs to a phone number
|
|
11
|
+
* TODO: [FEATURE] Allow for custom log levels and colors
|
|
12
|
+
* TODO: [FEATURE] Add a toggle to enable/disable individual plugins
|
|
13
|
+
* TODO: [FEATURE] Attempt automatically parse the environment variables for the config using special flags.
|
|
14
|
+
* This would allow for a more seamless integration with Docker and adjustments to the config without code changes.
|
|
15
|
+
* TODO: [FEATURE] Make `LOG_REPORT_PATH` a build in variable. This variable attempts to find the current file name and directory name for cleaner logs.
|
|
16
|
+
* LOG_REPORT_PATH=(path.basename(path.dirname(__filename)) === process.env.APP_NAME ? '/' : path.basename(path.dirname(__filename)) + '/') + path.basename(__filename, ".js")
|
|
17
|
+
* 2024-08-27 23:45:28 [trace ] [ID: 578060] [APP_NAME routes/instructions]: Logger initiated by routes/instructions with log level trace
|
|
18
|
+
* 2024-08-27 23:45:28 [trace ] [ID: 578060] [APP_NAME routes/create-and-sign]: Logger initiated by routes/create-and-sign with log level trace
|
|
19
|
+
* TODO: [FEATURE] Add a option to pass a banner. For example logger.banner('Project Name') would print a banner with the project name.
|
|
20
|
+
* TODO: [TESTING] Create a comprehensive test suite for all plugins.
|
|
21
|
+
* TODO: [BUG] Syslog plugin has incorrect log levels. (For example, info reports level 3, and reports as 11 in the Syslog server)
|
|
12
22
|
*/
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
25
|
* Change Log:
|
|
26
|
+
* v2.7.0 - 09/02/2024:
|
|
27
|
+
* [FEATURE] Added a toggle to enable/disable individual plugins. See documentation for more information.
|
|
28
|
+
* [NOTE] Changed how the plugins are loaded. Broken plugins will no longer crash the logger, rather they will be disabled.
|
|
29
|
+
*
|
|
16
30
|
* v2.6.2 - 08/15/2024:
|
|
17
31
|
* [DEPENDENCY] Added pg package for Postgres Plugin
|
|
18
32
|
* [FEATURE] Postgres Plugin
|
package/package.json
CHANGED
package/plugins/index.js
CHANGED
|
@@ -39,8 +39,25 @@ function initPlugins(config = {}) {
|
|
|
39
39
|
let pluginTransports = [];
|
|
40
40
|
try {
|
|
41
41
|
for (let plugin of config) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
try {
|
|
43
|
+
if (!plugin.name) {
|
|
44
|
+
throw new Error('Plugin name is required');
|
|
45
|
+
}
|
|
46
|
+
} catch (nameError) {
|
|
47
|
+
console.error('Error initializing plugins:', nameError.message);
|
|
48
|
+
console.error(nameError.stack);
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
if (!plugin.enabled) {
|
|
54
|
+
console.log(`Plugin ${plugin.name} is disabled`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
} catch (enabledError) {
|
|
58
|
+
console.error('Error initializing plugins:', enabledError.message);
|
|
59
|
+
console.error(enabledError.stack);
|
|
60
|
+
continue
|
|
44
61
|
}
|
|
45
62
|
|
|
46
63
|
try {
|