@autofleet/logger 2.0.0-beta-4 → 2.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.
Files changed (2) hide show
  1. package/index.js +6 -15
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const winston = require('winston');
2
- const { LoggingWinston } = require('@google-cloud/logging-winston');
3
2
  const sizeof = require('object-sizeof');
4
3
 
5
4
  const { createLogger } = winston;
@@ -7,12 +6,6 @@ require('dotenv').config();
7
6
 
8
7
  const { env } = process;
9
8
 
10
- const loggingWinston = new LoggingWinston();
11
- // https://github.com/googleapis/nodejs-logging-winston/issues/428
12
- loggingWinston.on('error', (err) => {
13
- console.error('Transport error', err);
14
- });
15
-
16
9
  const isProd = env.NODE_ENV === 'production';
17
10
 
18
11
  const infoEnvNmaes = [
@@ -38,10 +31,9 @@ const addLogsSize = winston.format((info) => {
38
31
  const logSize = sizeof(info);
39
32
  if (logSize > 256000) {
40
33
  console.log(`[WARNING] Found Oversized log with message "${info.message}"`);
41
- return { message: `Oversize log: ${info.message}`, logSize };
42
34
  }
43
35
 
44
- return { ...info, logSize };
36
+ return { message: info.message, logSize };
45
37
  });
46
38
 
47
39
  const enumerateErrorFormat = winston.format((info) => {
@@ -75,9 +67,11 @@ const enumerateErrorFormat = winston.format((info) => {
75
67
 
76
68
  const getFormat = () => {
77
69
  if (isProd) {
78
- return [
70
+ return winston.format.combine(
79
71
  addLogsSize(),
80
- ];
72
+ enumerateErrorFormat(),
73
+ winston.format.json(),
74
+ );
81
75
  }
82
76
 
83
77
  return winston.format.combine(
@@ -92,10 +86,7 @@ const createLoggerInstance = (level, exceptionHandlers) => {
92
86
  const logger = createLogger({
93
87
  level,
94
88
  format: getFormat(),
95
- transports: isProd ? [
96
- new winston.transports.Console(),
97
- loggingWinston,
98
- ] : [
89
+ transports: [
99
90
  new winston.transports.Console(),
100
91
  ],
101
92
  exceptionHandlers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/logger",
3
- "version": "2.0.0-beta-4",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "homepage": "https://github.com/Autofleet/logger",
25
25
  "dependencies": {
26
- "@google-cloud/logging-winston": "^4.1.3",
26
+ "@google-cloud/logging-winston": "^4.1.1",
27
27
  "dotenv": "^5.0.1",
28
28
  "jest": "^22.4.4",
29
29
  "object-sizeof": "^1.6.1",
30
- "winston": "^3.6.0"
30
+ "winston": "^3.3.3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "eslint": "^4.19.1",