ac-logger 3.0.5 → 4.0.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/.github/workflows/node.js.yml +12 -17
- package/CHANGELOG.md +26 -0
- package/README.md +1 -1
- package/eslint.config.js +30 -28
- package/index.js +8 -8
- package/package.json +6 -5
- package/test/test.js +3 -3
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
-
|
|
4
1
|
name: Node.js CI
|
|
5
2
|
|
|
6
3
|
on:
|
|
7
4
|
push:
|
|
8
|
-
branches: [ master
|
|
5
|
+
branches: [develop, master]
|
|
9
6
|
pull_request:
|
|
10
|
-
branches: [ master
|
|
7
|
+
branches: [develop, master]
|
|
11
8
|
|
|
12
9
|
jobs:
|
|
13
10
|
build:
|
|
14
|
-
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
15
13
|
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
14
|
strategy:
|
|
18
15
|
matrix:
|
|
19
|
-
node-version: [
|
|
20
|
-
|
|
16
|
+
node-version: [22.x, 24.x]
|
|
21
17
|
steps:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- run: yarn run test
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
- run: yarn install
|
|
24
|
+
- run: yarn run test
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# [4.0.0](https://github.com/admiralcloud/ac-logger/compare/v3.0.5..v4.0.0) (2026-04-04 13:14:46)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fix
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
* **App:** Package updates | MP | [5361eb16cb8b8320b9416785f1e68f9e832ec391](https://github.com/admiralcloud/ac-logger/commit/5361eb16cb8b8320b9416785f1e68f9e832ec391)
|
|
8
|
+
Package updates
|
|
9
|
+
Related issues:
|
|
10
|
+
* **Misc:** Requires Node 22+ | MP | [70a30278e37136a924ed67254071b66b55738772](https://github.com/admiralcloud/ac-logger/commit/70a30278e37136a924ed67254071b66b55738772)
|
|
11
|
+
Requires Node 22+
|
|
12
|
+
Related issues:
|
|
13
|
+
### Style
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
* **App:** Lint-fix | MP | [b93791fc3dbce7d7f0ed5f27c78711644b8bd88b](https://github.com/admiralcloud/ac-logger/commit/b93791fc3dbce7d7f0ed5f27c78711644b8bd88b)
|
|
17
|
+
Lint-fix
|
|
18
|
+
Related issues:
|
|
19
|
+
### Chores
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* **App:** Updated workflows | MP | [9a71ac0964bfb761cec4d770cd510eda46067e4a](https://github.com/admiralcloud/ac-logger/commit/9a71ac0964bfb761cec4d770cd510eda46067e4a)
|
|
23
|
+
Updated workflows
|
|
24
|
+
Related issues:
|
|
25
|
+
## BREAKING CHANGES
|
|
26
|
+
* **Misc:** Requires Node 22+
|
|
1
27
|
|
|
2
28
|
## [3.0.5](https://github.com/admiralcloud/ac-logger/compare/v3.0.4..v3.0.5) (2026-04-01 08:28:30)
|
|
3
29
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ Unified logging function for all backend applications of AdmiralCloud. Use it in
|
|
|
3
3
|
|
|
4
4
|
The purpose of the little app is to make sure that all applications use the same log format/notations.
|
|
5
5
|
|
|
6
|
-
[](https://github.com/AdmiralCloud/ac-logger/actions/workflows/node.js.yml)
|
|
6
|
+
[](https://github.com/AdmiralCloud/ac-logger/actions/workflows/node.js.yml) [](https://github.com/AdmiralCloud/ac-logger/actions/workflows/github-code-scanning/codeql)
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
Use it like Winston!
|
package/eslint.config.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
const globals = require('globals')
|
|
2
2
|
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
files: ['index.js', 'test/**.js'],
|
|
6
|
+
languageOptions: {
|
|
7
|
+
ecmaVersion: 2022,
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.commonjs,
|
|
11
|
+
...globals.es2015,
|
|
12
|
+
...globals.node,
|
|
13
|
+
expect: 'readonly',
|
|
14
|
+
describe: 'readonly',
|
|
15
|
+
it: 'readonly'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
'no-const-assign': 'error',
|
|
20
|
+
'space-before-function-paren': 'off',
|
|
21
|
+
'no-extra-semi': 'off',
|
|
22
|
+
'object-curly-spacing': ['error', 'always'],
|
|
23
|
+
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
24
|
+
'block-spacing': 'error',
|
|
25
|
+
'no-useless-escape': 'off',
|
|
26
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
27
|
+
'no-unused-vars': 'error',
|
|
28
|
+
'eqeqeq': 'error',
|
|
29
|
+
'no-var': 'error',
|
|
30
|
+
'curly': 'error',
|
|
31
|
+
'prefer-const': ['error', { ignoreReadBeforeAssign: true }]
|
|
17
32
|
}
|
|
18
|
-
},
|
|
19
|
-
rules: {
|
|
20
|
-
'no-const-assign': 'error', // Ensure this rule is enabled
|
|
21
|
-
'space-before-function-paren': 'off',
|
|
22
|
-
'no-extra-semi': 'off',
|
|
23
|
-
'object-curly-spacing': ['error', 'always'],
|
|
24
|
-
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
25
|
-
'no-useless-escape': 'off',
|
|
26
|
-
'standard/no-callback-literal': 'off',
|
|
27
|
-
'new-cap': 'off',
|
|
28
|
-
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
29
|
-
"no-unused-vars": "error", // we shouldn't clutter code with unused variables
|
|
30
|
-
"prefer-const": ["warn", { "ignoreReadBeforeAssign": true }],
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
]
|
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
28
28
|
// display accessKey, link (if applicable)
|
|
29
29
|
const message = data?.message ? ` ${data.message}` : ''
|
|
30
30
|
let cuid = data?.customerId ? data?.customerId : ''
|
|
31
|
-
if (data?.userId) cuid += `/${data.userId} `
|
|
31
|
+
if (data?.userId) { cuid += `/${data.userId} ` }
|
|
32
32
|
// colorize status codes
|
|
33
33
|
|
|
34
34
|
const statusCode = data?.statusCode
|
|
@@ -56,9 +56,9 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
56
56
|
|
|
57
57
|
// modern approach (fileName, functionName, sub) // TBD with team
|
|
58
58
|
const functionIdentifier = _.get(data, 'functionIdentifier') ? _.get(data, 'functionIdentifier') + ' | ' : ''
|
|
59
|
-
if (!fileName && _.get(data, 'fileName')) fileName = _.get(data, 'fileName')
|
|
60
|
-
if (!functionName && _.get(data, 'functionName')) functionName = _.get(data, 'functionName')
|
|
61
|
-
if (!subName && _.get(data, 'sub')) subName = _.get(data, 'sub')
|
|
59
|
+
if (!fileName && _.get(data, 'fileName')) { fileName = _.get(data, 'fileName') }
|
|
60
|
+
if (!functionName && _.get(data, 'functionName')) { functionName = _.get(data, 'functionName') }
|
|
61
|
+
if (!subName && _.get(data, 'sub')) { subName = _.get(data, 'sub') }
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
let message = data?.message
|
|
@@ -76,7 +76,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
76
76
|
if (data?.e instanceof Error) {
|
|
77
77
|
// log the stack
|
|
78
78
|
console.error(data?.e)
|
|
79
|
-
if (data?.e?.message) message += ' | ' + ( data?.e?.message || '')
|
|
79
|
+
if (data?.e?.message) { message += ' | ' + ( data?.e?.message || '') }
|
|
80
80
|
}
|
|
81
81
|
// TODO: for better readability, we shold use padding for fileName, functionname, etc
|
|
82
82
|
return `${data?.timestamp} ${data?.level} ${fileName}${functionName}${functionIdentifier}${subName}${prefixData}${message}`
|
|
@@ -149,7 +149,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
149
149
|
else {
|
|
150
150
|
_.forEach(transporters, item => {
|
|
151
151
|
const logTransport = new transports[item.type](item.options)
|
|
152
|
-
if (_.has(item, 'onRotate')) logTransport.on('rotate', item.onRotate)
|
|
152
|
+
if (_.has(item, 'onRotate')) { logTransport.on('rotate', item.onRotate) }
|
|
153
153
|
logTransports.push(logTransport)
|
|
154
154
|
})
|
|
155
155
|
}
|
|
@@ -158,10 +158,10 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
|
|
|
158
158
|
level,
|
|
159
159
|
transports: logTransports
|
|
160
160
|
}
|
|
161
|
-
if (_.get(customLevels, 'levels')) _.set(logConfig, 'levels', _.get(customLevels, 'levels'))
|
|
161
|
+
if (_.get(customLevels, 'levels')) { _.set(logConfig, 'levels', _.get(customLevels, 'levels')) }
|
|
162
162
|
|
|
163
163
|
const acLogger = createLogger(logConfig)
|
|
164
|
-
if (_.get(customLevels, 'colors')) addColors(_.get(customLevels, 'colors'))
|
|
164
|
+
if (_.get(customLevels, 'colors')) { addColors(_.get(customLevels, 'colors')) }
|
|
165
165
|
|
|
166
166
|
const changeLogLevel = (newLevel) => {
|
|
167
167
|
acLogger.transports.forEach((transport) => {
|
package/package.json
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-logger",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "4.0.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"lodash": "^4.
|
|
8
|
+
"lodash": "^4.18.1",
|
|
9
9
|
"moment": "^2.30.1",
|
|
10
10
|
"winston": "^3.19.0",
|
|
11
11
|
"winston-daily-rotate-file": "^5.0.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"ac-semantic-release": "^0.
|
|
14
|
+
"ac-semantic-release": "^1.0.1",
|
|
15
15
|
"chai": "^4.5.0",
|
|
16
|
-
"eslint": "^
|
|
16
|
+
"eslint": "^10.2.0",
|
|
17
|
+
"globals": "^17.4.0",
|
|
17
18
|
"intercept-stdout": "^0.1.2",
|
|
18
19
|
"mocha": "^11.7.5"
|
|
19
20
|
},
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"test": "mocha --reporter spec"
|
|
22
23
|
},
|
|
23
24
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
25
|
+
"node": ">=22.0.0"
|
|
25
26
|
},
|
|
26
27
|
"resolutions": {
|
|
27
28
|
"mocha/chokidar/braces": "^3.0.3",
|
package/test/test.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const { expect } = require('chai')
|
|
2
2
|
const aclog = require('../index')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const intercept = require("intercept-stdout");
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let captured_text = "";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const unhook_intercept = intercept(function(text) {
|
|
9
9
|
captured_text += text;
|
|
10
10
|
});
|
|
11
11
|
|