@apolitical/logger 2.0.0-beta.6 → 2.0.0-beta.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/logger",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.7",
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",
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({}, allowedLabels(), { 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(),