ntlogger 2.3.0 → 2.4.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/LICENSE +674 -674
- package/README.md +89 -89
- package/index.js +65 -57
- package/lib/logger.js +221 -219
- package/package.json +43 -38
- package/plugins/index.js +54 -0
- package/plugins/jest.js +60 -0
- package/plugins/mysql.js +175 -0
- package/plugins/sentry.js +51 -0
package/README.md
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
# NightTimeLogger
|
|
2
|
-
|
|
3
|
-
NightTimeLogger is a custom logging wrapper built on top of the Winston logging library. It provides a ready-to-go solution for integrating advanced logging functionalities into Node.js applications with ease.
|
|
4
|
-
|
|
5
|
-
[](https://github.com/NightSquawk/NightTimeLogger/actions/workflows/main.yml)
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- Custom log levels for fine-grained control over logging output.
|
|
10
|
-
- Dynamic color generation for visually appealing log messages.
|
|
11
|
-
- Custom session ID generation for tracking log sessions.
|
|
12
|
-
- Support for both file and console log formatters.
|
|
13
|
-
- Ability to configure log levels and formats to suit specific requirements.
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
To install NightTimeLogger, use npm:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install ntlogger
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
// Import the logger
|
|
27
|
-
const logger = require('ntlogger');
|
|
28
|
-
|
|
29
|
-
// Create a logger instance
|
|
30
|
-
const log = logger('MyApp');
|
|
31
|
-
|
|
32
|
-
// Log messages at different levels
|
|
33
|
-
log.info('Informational message');
|
|
34
|
-
log.warn('Warning message');
|
|
35
|
-
log.error('Error message');
|
|
36
|
-
log.debug('Debugging message');
|
|
37
|
-
log.trace('Trace message');
|
|
38
|
-
|
|
39
|
-
// Log internal messages
|
|
40
|
-
log.internal('Internal message');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Output
|
|
44
|
-
|
|
45
|
-
Check out [Quick Start](https://github.com/NightSquawk/NightTimeLogger/blob/main/examples/quick-start.js)
|
|
46
|
-

|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Check out [Full Configuration](https://github.com/NightSquawk/NightTimeLogger/blob/main/examples/full-configuration.js)
|
|
50
|
-

|
|
51
|
-
|
|
52
|
-
## Configuration Options
|
|
53
|
-
|
|
54
|
-
- `level`: The default log level for the logger instance.
|
|
55
|
-
- `console`: Whether to enable console logging. Defaults to `true`.
|
|
56
|
-
- `file`: Whether to enable file logging. Defaults to `true`.
|
|
57
|
-
- `path`: The directory path where log files will be saved.
|
|
58
|
-
- `maxSize`: The maximum size (in bytes) for each log file.
|
|
59
|
-
- `maxFiles`: The maximum number of log files to retain (rotating file strategy).
|
|
60
|
-
- `timestamp`: Whether to include timestamps in log messages. Defaults to `true`.
|
|
61
|
-
- `debug`: Whether to enable debug mode, which logs internal messages. Defaults to `false`.
|
|
62
|
-
|
|
63
|
-
## Custom Levels and Colors
|
|
64
|
-
NightTimeLogger provides custom log levels and colors for enhanced logging experience:
|
|
65
|
-
|
|
66
|
-
### Levels:
|
|
67
|
-
|
|
68
|
-
- trace: 5
|
|
69
|
-
- debug: 4
|
|
70
|
-
- info: 3
|
|
71
|
-
- warn: 2
|
|
72
|
-
- error: 1
|
|
73
|
-
- fatal: 0
|
|
74
|
-
- internal: -1
|
|
75
|
-
|
|
76
|
-
### Colors:
|
|
77
|
-
|
|
78
|
-
- trace: Light gray
|
|
79
|
-
- debug: White
|
|
80
|
-
- info: Green
|
|
81
|
-
- warn: Yellow
|
|
82
|
-
- error: Red
|
|
83
|
-
- fatal: Magenta
|
|
84
|
-
- internal: Bright yellow
|
|
85
|
-
|
|
86
|
-
## File and Console Formatters
|
|
87
|
-
NightTimeLogger supports both file and console log formatters. File-formatted logs are stored in the project's root `/logs` directory.
|
|
88
|
-
|
|
89
|
-
## License
|
|
1
|
+
# NightTimeLogger
|
|
2
|
+
|
|
3
|
+
NightTimeLogger is a custom logging wrapper built on top of the Winston logging library. It provides a ready-to-go solution for integrating advanced logging functionalities into Node.js applications with ease.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/NightSquawk/NightTimeLogger/actions/workflows/main.yml)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Custom log levels for fine-grained control over logging output.
|
|
10
|
+
- Dynamic color generation for visually appealing log messages.
|
|
11
|
+
- Custom session ID generation for tracking log sessions.
|
|
12
|
+
- Support for both file and console log formatters.
|
|
13
|
+
- Ability to configure log levels and formats to suit specific requirements.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To install NightTimeLogger, use npm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install ntlogger
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
// Import the logger
|
|
27
|
+
const logger = require('ntlogger');
|
|
28
|
+
|
|
29
|
+
// Create a logger instance
|
|
30
|
+
const log = logger('MyApp');
|
|
31
|
+
|
|
32
|
+
// Log messages at different levels
|
|
33
|
+
log.info('Informational message');
|
|
34
|
+
log.warn('Warning message');
|
|
35
|
+
log.error('Error message');
|
|
36
|
+
log.debug('Debugging message');
|
|
37
|
+
log.trace('Trace message');
|
|
38
|
+
|
|
39
|
+
// Log internal messages
|
|
40
|
+
log.internal('Internal message');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Output
|
|
44
|
+
|
|
45
|
+
Check out [Quick Start](https://github.com/NightSquawk/NightTimeLogger/blob/main/examples/quick-start.js)
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Check out [Full Configuration](https://github.com/NightSquawk/NightTimeLogger/blob/main/examples/full-configuration.js)
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
## Configuration Options
|
|
53
|
+
|
|
54
|
+
- `level`: The default log level for the logger instance.
|
|
55
|
+
- `console`: Whether to enable console logging. Defaults to `true`.
|
|
56
|
+
- `file`: Whether to enable file logging. Defaults to `true`.
|
|
57
|
+
- `path`: The directory path where log files will be saved.
|
|
58
|
+
- `maxSize`: The maximum size (in bytes) for each log file.
|
|
59
|
+
- `maxFiles`: The maximum number of log files to retain (rotating file strategy).
|
|
60
|
+
- `timestamp`: Whether to include timestamps in log messages. Defaults to `true`.
|
|
61
|
+
- `debug`: Whether to enable debug mode, which logs internal messages. Defaults to `false`.
|
|
62
|
+
|
|
63
|
+
## Custom Levels and Colors
|
|
64
|
+
NightTimeLogger provides custom log levels and colors for enhanced logging experience:
|
|
65
|
+
|
|
66
|
+
### Levels:
|
|
67
|
+
|
|
68
|
+
- trace: 5
|
|
69
|
+
- debug: 4
|
|
70
|
+
- info: 3
|
|
71
|
+
- warn: 2
|
|
72
|
+
- error: 1
|
|
73
|
+
- fatal: 0
|
|
74
|
+
- internal: -1
|
|
75
|
+
|
|
76
|
+
### Colors:
|
|
77
|
+
|
|
78
|
+
- trace: Light gray
|
|
79
|
+
- debug: White
|
|
80
|
+
- info: Green
|
|
81
|
+
- warn: Yellow
|
|
82
|
+
- error: Red
|
|
83
|
+
- fatal: Magenta
|
|
84
|
+
- internal: Bright yellow
|
|
85
|
+
|
|
86
|
+
## File and Console Formatters
|
|
87
|
+
NightTimeLogger supports both file and console log formatters. File-formatted logs are stored in the project's root `/logs` directory.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
90
|
NightTimeLogger is licensed under the [GPL-3.0 License](https://opensource.org/licenses/GPL-3.0).
|
package/index.js
CHANGED
|
@@ -1,58 +1,66 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ntlogger
|
|
3
|
-
* Copyright(c) 2024
|
|
4
|
-
* GPL-3.0 Licensed
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Change Log:
|
|
9
|
-
*
|
|
10
|
-
* v2.
|
|
11
|
-
*
|
|
12
|
-
* Fixed
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* Added
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* ntlogger
|
|
3
|
+
* Copyright(c) 2024 KR
|
|
4
|
+
* GPL-3.0 Licensed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Change Log:
|
|
9
|
+
*
|
|
10
|
+
* v2.4.0 - 08/01/2024:
|
|
11
|
+
* [NOTE] Damn its been 4 months.. kinda. forgot to log last changes
|
|
12
|
+
* [CRITICAL] Fixed `includes` in package.json which prevented plugins folder from being pushed to npmjs.com
|
|
13
|
+
* [QA] Added test cases using jest
|
|
14
|
+
* [Feature] Added session ID to logger meta, try `console.log(log.defaultMeta.ID)`
|
|
15
|
+
* [Feature] Created the plugin jest. Added a custom transport for in memory logging and testing
|
|
16
|
+
* [Feature] Created the config var `skipCache` to allow you to create a new logger instance within the same file. (Usual behavior is to return the same instance within the same file)
|
|
17
|
+
*
|
|
18
|
+
* v2.2.3 - 04/01/2024:
|
|
19
|
+
* Reduced GitHub Actions to only NPM publish
|
|
20
|
+
* Fixed export
|
|
21
|
+
* Modified readme and examples
|
|
22
|
+
*
|
|
23
|
+
* v2.2.2 - 03/31/2024:
|
|
24
|
+
* Take 2 on setting up CI with GitHub Actions to NPM
|
|
25
|
+
* Housekeeping
|
|
26
|
+
*
|
|
27
|
+
* v2.2.1 - 03/31/2024:
|
|
28
|
+
* Tried and failed to setup CI with GitHub Actions to NPM
|
|
29
|
+
*
|
|
30
|
+
* v2.2.0 - 03/31/2024:
|
|
31
|
+
* Renamed project to NightTimeLogger, no longer a daytime logger (old name was Nightly-Logger)
|
|
32
|
+
* Published the project on NPM
|
|
33
|
+
* Added a location parameter to the logger function
|
|
34
|
+
* Modified the logger instance creation to include the location in the metadata
|
|
35
|
+
* Added a map to store logger instances by location instead of one global instance
|
|
36
|
+
* This allows the location to be included in the metadata of each log statement
|
|
37
|
+
* Added a custom 'internal' log level to log internal messages
|
|
38
|
+
* Shortened the output by removing Session from Session ID to increase line availability for messages
|
|
39
|
+
* Increased log level padding to 8 characters to ensure consistent spacing
|
|
40
|
+
* (this looks a bit weird, not sure if I like it but I also tried centered log levels and it no look good :( )
|
|
41
|
+
* Added many configuration options to the logger function (level, internal, console, file, filename, path, maxSize, maxFiles, timestamp)
|
|
42
|
+
*
|
|
43
|
+
* TODO: locations has a weird bug that carries location from instance to instance, ONLY, when another instanced is called
|
|
44
|
+
* from a different file. I have no idea why this is happening.
|
|
45
|
+
* i.e. app.js calls route.js then back to app.js but the location is still route.js. This does not happen when directly
|
|
46
|
+
* calling route.js.
|
|
47
|
+
* TODO: probably rewrite the whole thing to improve readability and maintainability
|
|
48
|
+
* TODO: cry
|
|
49
|
+
* TODO: timestamp, filename have not been tested nor implemented
|
|
50
|
+
*
|
|
51
|
+
* v2.1.0 - 03/17/2024:
|
|
52
|
+
* Modified custom log colors to use ANSI escape codes
|
|
53
|
+
* Changed the console formatter to paint the level and message with the corresponding color
|
|
54
|
+
* Modified the color generation formula. Now with prettier colors!
|
|
55
|
+
*
|
|
56
|
+
* v2.0.0 - 01/20/2024:
|
|
57
|
+
* Added bright color generation
|
|
58
|
+
* Added session ID generation
|
|
59
|
+
* Added separate console and file formatters
|
|
60
|
+
* Added rotating file transport with 5 files of 1MB each (5MB total)
|
|
61
|
+
*
|
|
62
|
+
* v1.0.0 - 10/18/2023:
|
|
63
|
+
* Initial release
|
|
64
|
+
*/
|
|
65
|
+
|
|
58
66
|
module.exports = require('./lib/logger');
|