ac-logger 2.3.1 → 2.3.2
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/CHANGELOG.md +15 -0
- package/index.js +14 -2
- package/package.json +3 -3
- package/test/test.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<a name="2.3.2"></a>
|
|
2
|
+
|
|
3
|
+
## [2.3.2](https://github.com/admiralcloud/ac-logger/compare/v2.3.1..v2.3.2) (2024-05-08 15:32:14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fix
|
|
7
|
+
|
|
8
|
+
* **App:** Added option to change logLevel during runtime | MP | [1e59bed4b7d56dff95584fdf528f4dd931e3e6a2](https://github.com/admiralcloud/ac-logger/commit/1e59bed4b7d56dff95584fdf528f4dd931e3e6a2)
|
|
9
|
+
It is now possible to change loglevel after init
|
|
10
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* **App:** Updated packages | MP | [af832d3e7cb148e625b0bcd0756d69044bcb812d](https://github.com/admiralcloud/ac-logger/commit/af832d3e7cb148e625b0bcd0756d69044bcb812d)
|
|
14
|
+
Updated packages
|
|
15
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
1
16
|
<a name="2.3.1"></a>
|
|
2
17
|
|
|
3
18
|
## [2.3.1](https://github.com/admiralcloud/ac-logger/compare/v2.3.0..v2.3.1) (2024-03-10 12:31:44)
|
package/index.js
CHANGED
|
@@ -91,6 +91,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
91
91
|
// structured logging for analysis and querying within the CloudWatch service.
|
|
92
92
|
if (applicationLogs?.enabled) {
|
|
93
93
|
let filename = applicationLogs?.filename || 'application.log'
|
|
94
|
+
const symlinkName = filename
|
|
94
95
|
if (filename.endsWith('.log')) {
|
|
95
96
|
// If the filename ends with .log, insert -%DATE% before the extension
|
|
96
97
|
filename = filename.replace(/\.log$/, '-%DATE%.log');
|
|
@@ -111,7 +112,9 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
111
112
|
format.timestamp(),
|
|
112
113
|
splatFormatter(),
|
|
113
114
|
format.json()
|
|
114
|
-
)
|
|
115
|
+
),
|
|
116
|
+
createSymlink: true, // Enable symlink creation
|
|
117
|
+
symlinkName: symlinkName // Fixed name for the current log file symlink
|
|
115
118
|
})
|
|
116
119
|
|
|
117
120
|
transport.on('error', error => {
|
|
@@ -144,7 +147,15 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
144
147
|
const acLogger = createLogger(logConfig)
|
|
145
148
|
if (_.get(customLevels, 'colors')) addColors(_.get(customLevels, 'colors'))
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
const changeLogLevel = (newLevel) => {
|
|
151
|
+
acLogger.transports.forEach((transport) => {
|
|
152
|
+
const currentLevel = transport.level || acLogger.level; // Fallback to the logger's default level
|
|
153
|
+
if (currentLevel !== newLevel) {
|
|
154
|
+
console.log(`Changing level of ${transport.name} from ${currentLevel} to ${newLevel}`);
|
|
155
|
+
transport.level = newLevel; // Confirm this line is executing
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
148
159
|
|
|
149
160
|
const headline = (params) => {
|
|
150
161
|
acLogger.info('')
|
|
@@ -228,6 +239,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
228
239
|
|
|
229
240
|
return {
|
|
230
241
|
acLogger,
|
|
242
|
+
changeLogLevel,
|
|
231
243
|
headline,
|
|
232
244
|
functionStartLine,
|
|
233
245
|
listing,
|
package/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-logger",
|
|
6
|
-
"version": "2.3.
|
|
6
|
+
"version": "2.3.2",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"lodash": "^4.17.21",
|
|
9
9
|
"moment": "^2.30.1",
|
|
10
|
-
"winston": "^3.
|
|
10
|
+
"winston": "^3.13.0",
|
|
11
11
|
"winston-daily-rotate-file": "^5.0.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"chai": "^4.4.1",
|
|
16
16
|
"eslint": "^8.57.0",
|
|
17
17
|
"intercept-stdout": "^0.1.2",
|
|
18
|
-
"mocha": "^10.
|
|
18
|
+
"mocha": "^10.4.0",
|
|
19
19
|
"mocha-jenkins-reporter": "^0.4.8"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
package/test/test.js
CHANGED
|
@@ -23,6 +23,30 @@ describe('Tests', () => {
|
|
|
23
23
|
expect(lines[9]).to.contain('AppName')
|
|
24
24
|
expect(lines[9]).to.contain('myApp')
|
|
25
25
|
})
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
it('Log info', () => {
|
|
29
|
+
captured_text = ''
|
|
30
|
+
const log = aclog().acLogger
|
|
31
|
+
log.info('Hello Info')
|
|
32
|
+
log.debug('Hello Debug')
|
|
33
|
+
const lines = captured_text.split('\n')
|
|
34
|
+
expect(lines[0]).to.contain('INFO')
|
|
35
|
+
expect(lines[1]).not.to.contain('DEBUG')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('Log debug', () => {
|
|
39
|
+
const loggerSetup = aclog();
|
|
40
|
+
const log = loggerSetup.acLogger
|
|
41
|
+
loggerSetup.changeLogLevel('debug')
|
|
42
|
+
captured_text = ''
|
|
43
|
+
log.info('Hello Info')
|
|
44
|
+
log.debug('Hello Debug')
|
|
45
|
+
const lines = captured_text.split('\n')
|
|
46
|
+
expect(lines[0]).to.contain('INFO')
|
|
47
|
+
expect(lines[1]).to.contain('DEBUG')
|
|
48
|
+
})
|
|
49
|
+
|
|
26
50
|
|
|
27
51
|
it('Unhook', () => {
|
|
28
52
|
unhook_intercept()
|