ac-logger 2.3.2 → 3.0.1

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 CHANGED
@@ -1,3 +1,34 @@
1
+
2
+ ## [3.0.1](https://github.com/admiralcloud/ac-logger/compare/v3.0.0..v3.0.1) (2025-04-19 17:49:39)
3
+
4
+
5
+ ### Bug Fix
6
+
7
+ * **App:** Package updates | MP | [5c7ca057d9079fb148b6106e805839e915d7da84](https://github.com/admiralcloud/ac-logger/commit/5c7ca057d9079fb148b6106e805839e915d7da84)
8
+ Package updates
9
+ Related issues:
10
+ <a name="3.0.0"></a>
11
+
12
+ # [3.0.0](https://github.com/admiralcloud/ac-logger/compare/v2.3.2..v3.0.0) (2024-08-09 15:08:00)
13
+
14
+
15
+ ### Bug Fix
16
+
17
+ * **App:** Add colorization based on statusCode | MP | [e7d87144520ae667dce9e25b0a8c672dadacddc8](https://github.com/admiralcloud/ac-logger/commit/e7d87144520ae667dce9e25b0a8c672dadacddc8)
18
+ Add colorization based on statusCode
19
+ Related issues: [undefined/undefined#master](undefined/browse/master)
20
+ ### Style
21
+
22
+ * **App:** Lint fix | MP | [4c4c1edaecd3f94acf688fabdd78687212a12b31](https://github.com/admiralcloud/ac-logger/commit/4c4c1edaecd3f94acf688fabdd78687212a12b31)
23
+ Lint fix
24
+ Related issues: [undefined/undefined#master](undefined/browse/master)
25
+ ### Chores
26
+
27
+ * **App:** Updated packages | MP | [a2b6d3244a9db6cdd2af978fc15a0d5cfec4408d](https://github.com/admiralcloud/ac-logger/commit/a2b6d3244a9db6cdd2af978fc15a0d5cfec4408d)
28
+ Updated packages
29
+ Related issues: [undefined/undefined#master](undefined/browse/master)
30
+ ## BREAKING CHANGES
31
+ * **App:** Minimum Node version 18
1
32
  <a name="2.3.2"></a>
2
33
 
3
34
  ## [2.3.2](https://github.com/admiralcloud/ac-logger/compare/v2.3.1..v2.3.2) (2024-05-08 15:32:14)
@@ -0,0 +1,32 @@
1
+ const globals = require('globals')
2
+
3
+ module.exports = {
4
+ ignores: [
5
+ 'config/env/**'
6
+ ],
7
+ languageOptions: {
8
+ ecmaVersion: 2022,
9
+ sourceType: 'module',
10
+ globals: {
11
+ ...globals.commonjs,
12
+ ...globals.es2015,
13
+ ...globals.node,
14
+ expect: 'readonly',
15
+ describe: 'readonly',
16
+ it: 'readonly'
17
+ }
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
+ }
32
+ }
package/index.js CHANGED
@@ -26,10 +26,26 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
26
26
  // http log format
27
27
  if (level === 'http' && data?.controller) {
28
28
  // display accessKey, link (if applicable)
29
- let message = data?.message ? ` ${data.message}` : ''
29
+ const message = data?.message ? ` ${data.message}` : ''
30
30
  let cuid = data?.customerId ? data?.customerId : ''
31
31
  if (data?.userId) cuid += `/${data.userId} `
32
- return `${data?.timestamp} ${data?.level} ${data?.ip} ${data?.iso2 || ''} ${data?.accessKey || ''} ${cuid}${data?.controller} ${data?.action}${message} | ${data?.statusCode} | ${data?.performance?.executionTime}ms`
32
+ // colorize status codes
33
+
34
+ const statusCode = data?.statusCode
35
+ let displayStatusCode = (statusCode || ' ')
36
+ if (statusCode >= 500) {
37
+ displayStatusCode = `\x1B[35m${statusCode}\x1B[0m`
38
+ }
39
+ else if (statusCode >= 400) {
40
+ displayStatusCode = `\x1B[31m${statusCode}\x1B[0m`
41
+ }
42
+ else if (statusCode >= 300) {
43
+ displayStatusCode = `\x1B[33m${statusCode}\x1B[0m`
44
+ }
45
+ else if (statusCode >= 200) {
46
+ displayStatusCode = `\x1B[32m${statusCode}\x1B[0m`
47
+ }
48
+ return `${data?.timestamp} ${data?.level} ${data?.ip} ${data?.iso2 || ''} ${data?.accessKey || ''} ${cuid}${data?.controller} ${data?.action}${message} | ${displayStatusCode} | ${data?.performance?.executionTime}ms`
33
49
  }
34
50
  else {
35
51
  const meta = data?.meta
@@ -39,7 +55,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
39
55
  let subName = _.get(meta, 'sub') ? _.get(meta, 'sub') + ' | ' : _.get(data, 'sub') ? _.get(data, 'sub') + ' | ' : ''
40
56
 
41
57
  // modern approach (fileName, functionName, sub) // TBD with team
42
- let functionIdentifier = _.get(data, 'functionIdentifier') ? _.get(data, 'functionIdentifier') + ' | ' : ''
58
+ const functionIdentifier = _.get(data, 'functionIdentifier') ? _.get(data, 'functionIdentifier') + ' | ' : ''
43
59
  if (!fileName && _.get(data, 'fileName')) fileName = _.get(data, 'fileName')
44
60
  if (!functionName && _.get(data, 'functionName')) functionName = _.get(data, 'functionName')
45
61
  if (!subName && _.get(data, 'sub')) subName = _.get(data, 'sub')
@@ -48,8 +64,8 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
48
64
  let message = data?.message
49
65
 
50
66
 
51
- let prefix = []
52
- let dataFromPrefix = []
67
+ const prefix = []
68
+ const dataFromPrefix = []
53
69
  _.forEach(prefixFields, item => {
54
70
  if (_.get(meta, _.get(item, 'field'))) {
55
71
  prefix.push(_.get(item, 'short'))
@@ -151,7 +167,7 @@ module.exports = ({ prefixFields = [], timestampFormat = 'YYYY-MM-DD HH:mm:ss',
151
167
  acLogger.transports.forEach((transport) => {
152
168
  const currentLevel = transport.level || acLogger.level; // Fallback to the logger's default level
153
169
  if (currentLevel !== newLevel) {
154
- console.log(`Changing level of ${transport.name} from ${currentLevel} to ${newLevel}`);
170
+ console.warn(`Changing level of ${transport.name} from ${currentLevel} to ${newLevel}`);
155
171
  transport.level = newLevel; // Confirm this line is executing
156
172
  }
157
173
  });
package/package.json CHANGED
@@ -3,19 +3,19 @@
3
3
  "author": "Mark Poepping (https://www.admiralcloud.com)",
4
4
  "license": "MIT",
5
5
  "repository": "admiralcloud/ac-logger",
6
- "version": "2.3.2",
6
+ "version": "3.0.1",
7
7
  "dependencies": {
8
8
  "lodash": "^4.17.21",
9
9
  "moment": "^2.30.1",
10
- "winston": "^3.13.0",
10
+ "winston": "^3.17.0",
11
11
  "winston-daily-rotate-file": "^5.0.0"
12
12
  },
13
13
  "devDependencies": {
14
- "ac-semantic-release": "^0.4.2",
15
- "chai": "^4.4.1",
16
- "eslint": "^8.57.0",
14
+ "ac-semantic-release": "^0.4.5",
15
+ "chai": "^4.5.0",
16
+ "eslint": "^9.25.0",
17
17
  "intercept-stdout": "^0.1.2",
18
- "mocha": "^10.4.0",
18
+ "mocha": "^11.1.0",
19
19
  "mocha-jenkins-reporter": "^0.4.8"
20
20
  },
21
21
  "scripts": {
@@ -23,6 +23,10 @@
23
23
  "test-jenkins": "JUNIT_REPORT_PATH=./report.xml mocha --colors --reporter mocha-jenkins-reporter --reporter-options junit_report_name='ACLogger'"
24
24
  },
25
25
  "engines": {
26
- "node": ">=16.0.0"
27
- }
26
+ "node": ">=18.0.0"
27
+ },
28
+ "resolutions": {
29
+ "mocha/chokidar/braces": "^3.0.3"
30
+ },
31
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
28
32
  }
package/.eslintrc.js DELETED
@@ -1,27 +0,0 @@
1
- const config = {
2
- root: true,
3
- 'env': {
4
- 'commonjs': true,
5
- 'es2020': true,
6
- 'node': true
7
- },
8
- 'extends': 'eslint:recommended',
9
- "rules": {
10
- "space-before-function-paren": 0,
11
- "no-extra-semi": 0,
12
- "object-curly-spacing": ["error", "always"],
13
- "brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
14
- "no-useless-escape": 0,
15
- "standard/no-callback-literal": 0,
16
- "new-cap": 0
17
- },
18
- globals: {
19
- describe: true,
20
- it: true
21
- },
22
- 'parserOptions': {
23
- 'ecmaVersion': 2022
24
- },
25
- }
26
-
27
- module.exports = config