@autofleet/node-common 1.1.24 → 1.1.25
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/logger/index.js +10 -4
- package/package.json +1 -1
package/logger/index.js
CHANGED
|
@@ -21,7 +21,8 @@ const getLevel = () => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const getFormat = () => {
|
|
24
|
-
if (env.
|
|
24
|
+
if (env.AF_SERVICE_NAME) {
|
|
25
|
+
// Runing on cluster
|
|
25
26
|
return winston.format.json();
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -33,15 +34,20 @@ const getFormat = () => {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const createLoggerInstance = (level, transports) => {
|
|
36
|
-
const
|
|
37
|
+
const options = {
|
|
37
38
|
format: getFormat(),
|
|
38
39
|
transports: [
|
|
39
40
|
new winston.transports.Console(),
|
|
40
|
-
loggingWinston,
|
|
41
41
|
],
|
|
42
42
|
exceptionHandlers: transports,
|
|
43
43
|
exitOnError: false,
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (env.AF_SERVICE_NAME) {
|
|
47
|
+
options.transports.push(loggingWinston);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const logger = createLogger(options);
|
|
45
51
|
|
|
46
52
|
return logger;
|
|
47
53
|
};
|