ac-logger 2.1.0 → 2.2.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/CHANGELOG.md +10 -0
- package/index.js +8 -5
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<a name="2.2.0"></a>
|
|
2
|
+
|
|
3
|
+
# [2.2.0](https://github.com/admiralcloud/ac-logger/compare/v2.1.0..v2.2.0) (2023-07-26 07:02:00)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Feature
|
|
7
|
+
|
|
8
|
+
* **App:** Add option for log rotation | MP | [e4b0b2163b1cefdd37aba734b7e28349a0a7e658](https://github.com/admiralcloud/ac-logger/commit/e4b0b2163b1cefdd37aba734b7e28349a0a7e658)
|
|
9
|
+
You can use winston-daily-rotate-file with ac-logger
|
|
10
|
+
Related issues: [/issues#undefined](https://github.com//issues/undefined)
|
|
1
11
|
<a name="2.1.0"></a>
|
|
2
12
|
|
|
3
13
|
# [2.1.0](https://github.com/admiralcloud/ac-logger/compare/v2.0.1..v2.1.0) (2023-07-26 06:39:56)
|
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@ const _ = require('lodash')
|
|
|
2
2
|
const moment = require('moment')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
|
-
const { createLogger, format, transports, addColors } = require('winston')
|
|
5
|
+
const { createLogger, format, transports, addColors } = require('winston')
|
|
6
|
+
require('winston-daily-rotate-file')
|
|
6
7
|
|
|
7
8
|
module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss', level = (process.env.NODE_ENV === 'production' ? 'info' : 'verbose'), headLength = 80, padLength = 12, customLevels, additionalTransports } = {}) => {
|
|
8
9
|
const precisionMap = [
|
|
@@ -30,7 +31,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
30
31
|
console.error(e)
|
|
31
32
|
if (_.get(e, 'message')) message += ' | ' + _.get(e, 'message', '')
|
|
32
33
|
}
|
|
33
|
-
return `${timestamp} ${level} ${fileName}${functionName}${subName}${prefixData}${message}
|
|
34
|
+
return `${timestamp} ${level} ${fileName}${functionName}${subName}${prefixData}${message}`
|
|
34
35
|
})
|
|
35
36
|
|
|
36
37
|
const logConfig = {
|
|
@@ -42,7 +43,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
42
43
|
format.errors({ stack: true }),
|
|
43
44
|
format(info => {
|
|
44
45
|
info.level = _.padEnd(info.level.toUpperCase(), 8)
|
|
45
|
-
return info
|
|
46
|
+
return info
|
|
46
47
|
})(),
|
|
47
48
|
format.colorize(),
|
|
48
49
|
format.splat(),
|
|
@@ -59,8 +60,10 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
59
60
|
|
|
60
61
|
// Array of objects with type (e.g. File) and options for that type
|
|
61
62
|
if (_.size(additionalTransports)) {
|
|
62
|
-
_.forEach(additionalTransports,
|
|
63
|
-
|
|
63
|
+
_.forEach(additionalTransports, additionalTransport => {
|
|
64
|
+
const transport = new transports[additionalTransport.type](additionalTransport.options)
|
|
65
|
+
if (_.has(additionalTransport, 'onRotate')) transport.on('rotate', additionalTransport.onRotate)
|
|
66
|
+
acLogger.add(transport)
|
|
64
67
|
})
|
|
65
68
|
}
|
|
66
69
|
|
package/package.json
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-logger",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.2.0",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"lodash": "^4.17.21",
|
|
9
9
|
"moment": "^2.29.4",
|
|
10
|
-
"winston": "^3.10.0"
|
|
10
|
+
"winston": "^3.10.0",
|
|
11
|
+
"winston-daily-rotate-file": "^4.7.1"
|
|
11
12
|
},
|
|
12
13
|
"devDependencies": {
|
|
13
14
|
"ac-semantic-release": "^0.4.2",
|