@apolitical/logger 2.0.0-beta.5 → 2.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
@@ -5,14 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.1] - 2022-01-31
9
+ ### Fixed
10
+ - Node.js version
8
11
 
9
12
  ## [2.0.0] - 2022-01-18
10
13
  ### Changed
11
- - Dependencies
12
- - Node version
13
- - Labels definition instead of metadata
14
+ - Updated dependencies
15
+ - Upgraded Node.js version
16
+ - Revamped GitLab pipelines
17
+ - Renamed `metadata` to `labels` to allow consistency with logger middleware
14
18
  ### Added
15
- - Logger middleware
19
+ - Exposed logger middleware
20
+ ### Removed
21
+ - Filtered winston logger functionality
22
+ - Restricted metadata
16
23
 
17
24
  ## [1.0.2] - 2021-07-08
18
25
  ### Updated
package/README.md CHANGED
@@ -6,7 +6,7 @@ Node.js module to expose Apolitical's logger service
6
6
 
7
7
  Requires the following to run:
8
8
 
9
- - [node.js][node] 16.13.2+
9
+ - [node.js][node] 16.13.0+
10
10
  - [yarn][yarn]
11
11
 
12
12
  [node]: https://nodejs.org/en/download/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/logger",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.1",
4
4
  "description": "Node.js module to expose Apolitical's logger service",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",
@@ -25,19 +25,19 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@google-cloud/logging-winston": "4.1.1",
28
- "awilix": "6.0.0",
29
- "winston": "3.4.0"
28
+ "awilix": "6.1.0",
29
+ "winston": "3.5.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@apolitical/eslint-config": "1.0.0-beta.0",
32
+ "@apolitical/eslint-config": "1.0.2",
33
33
  "audit-ci": "5.1.2",
34
34
  "husky": "7.0.4",
35
35
  "jest": "27.4.7",
36
36
  "jest-junit": "13.0.0",
37
- "lint-staged": "12.2.0"
37
+ "lint-staged": "12.3.2"
38
38
  },
39
39
  "engines": {
40
- "node": ">=16.13.2"
40
+ "node": ">=16.13.0"
41
41
  },
42
42
  "eslintConfig": {
43
43
  "extends": "@apolitical/eslint-config/base.config"
package/src/config.js CHANGED
@@ -9,7 +9,6 @@ module.exports = {
9
9
  },
10
10
  LOGGER: {
11
11
  LOGGING_LEVELS: ['error', 'warn', 'info', 'debug'],
12
- ALLOWED_LABELS: ['name', 'version'],
13
12
  TRANSPORTS: {
14
13
  FILE: {
15
14
  ERROR_OPTIONS: {
@@ -2,20 +2,11 @@
2
2
 
3
3
  module.exports =
4
4
  ({ path, winston, winstonGoogle, config }) =>
5
- ({ logLevel = 'info', labels = {} }) => {
6
- const { LOGGING_LEVELS, ALLOWED_LABELS } = config.LOGGER;
5
+ ({ labels = {}, logLevel = 'info' }) => {
6
+ const { LOGGING_LEVELS } = config.LOGGER;
7
7
  const { ERROR_OPTIONS, COMBINED_OPTIONS } = config.LOGGER.TRANSPORTS.FILE;
8
8
  const { CLOUD_FUNCTION, CREDENTIALS } = config.GOOGLE;
9
9
 
10
- function allowedLabels() {
11
- return ALLOWED_LABELS.reduce((acc, cv) => {
12
- if (labels[cv]) {
13
- acc[cv] = labels[cv];
14
- }
15
- return acc;
16
- }, {});
17
- }
18
-
19
10
  function loggingLevels() {
20
11
  return LOGGING_LEVELS.reduce((acc, cv, idx) => {
21
12
  acc[cv] = idx;
@@ -52,10 +43,10 @@ module.exports =
52
43
  }
53
44
 
54
45
  function createWrapper(logger) {
55
- function where(filePath, method) {
46
+ function where(filePath, method, otherLabels = {}) {
56
47
  const file = path.basename(filePath);
57
48
  const childLogger = logger.child({
58
- labels: Object.assign({}, logger.labels, { file, method }),
49
+ labels: Object.assign({ file, method }, labels, otherLabels),
59
50
  });
60
51
  return createWrapper(childLogger);
61
52
  }
@@ -66,7 +57,7 @@ module.exports =
66
57
  }
67
58
 
68
59
  const loggerInstance = winston.createLogger({
69
- labels: allowedLabels(),
60
+ labels,
70
61
  level: logLevel,
71
62
  levels: loggingLevels(),
72
63
  format: loggerFormat(),