@autofleet/logger 2.0.0-beta-2 → 2.0.0-beta-4

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 +9 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -8,6 +8,11 @@ require('dotenv').config();
8
8
  const { env } = process;
9
9
 
10
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
+
11
16
  const isProd = env.NODE_ENV === 'production';
12
17
 
13
18
  const infoEnvNmaes = [
@@ -33,6 +38,7 @@ const addLogsSize = winston.format((info) => {
33
38
  const logSize = sizeof(info);
34
39
  if (logSize > 256000) {
35
40
  console.log(`[WARNING] Found Oversized log with message "${info.message}"`);
41
+ return { message: `Oversize log: ${info.message}`, logSize };
36
42
  }
37
43
 
38
44
  return { ...info, logSize };
@@ -69,7 +75,9 @@ const enumerateErrorFormat = winston.format((info) => {
69
75
 
70
76
  const getFormat = () => {
71
77
  if (isProd) {
72
- return undefined;
78
+ return [
79
+ addLogsSize(),
80
+ ];
73
81
  }
74
82
 
75
83
  return winston.format.combine(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/logger",
3
- "version": "2.0.0-beta-2",
3
+ "version": "2.0.0-beta-4",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
@@ -27,7 +27,7 @@
27
27
  "dotenv": "^5.0.1",
28
28
  "jest": "^22.4.4",
29
29
  "object-sizeof": "^1.6.1",
30
- "winston": "^3.3.3"
30
+ "winston": "^3.6.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "eslint": "^4.19.1",