Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 935339c

Browse files
butlerxWardormeur
authored andcommitted
remove unneeded data from production logs
1 parent 1f8a634 commit 935339c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM mhart/alpine-node:0.10.48
22
MAINTAINER butlerx <[email protected]>
3+
ENV NODE_ENV=production
34
ARG DEP_VERSION=latest
45
RUN apk add --update git build-base python postgresql-client && \
56
mkdir -p /usr/src/app

dev.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM mhart/alpine-node:0.10.48
22
MAINTAINER butlerx <[email protected]>
3-
3+
ENV NODE_ENV=development
44
RUN apk add --update git build-base python postgresql-client && \
55
mkdir -p /usr/src/app /usr/src/cp-translations
66
COPY docker-entrypoint.sh /usr/src

service.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ config.log = log.log;
1414
var util = require('util');
1515
var dgram = require('dgram');
1616

17-
seneca.log.info('using config', JSON.stringify(config, null, 4));
17+
if (process.env.NODE_ENV !== 'production') {
18+
seneca.log.info('using config', JSON.stringify(config, null, 4));
19+
}
1820

1921
seneca.options(config);
2022
seneca.decorate('customValidatorLogFormatter', require('./lib/custom-validator-log-formatter'));
@@ -26,10 +28,16 @@ if (process.env.MAILTRAP_ENABLED === 'true') {
2628
}
2729

2830
function shutdown (err) {
29-
if (err !== void 0 && err.stack !== void 0) {
30-
console.error(new Date().toString() + ' FATAL: UncaughtException, please report: ' + util.inspect(err));
31-
console.error(util.inspect(err.stack));
32-
console.trace();
31+
if (err !== undefined) {
32+
var error = {
33+
date: new Date().toString(),
34+
msg: err.stack !== undefined
35+
? 'FATAL: UncaughtException, please report: ' + util.inspect(err.stack)
36+
: 'FATAL: UncaughtException, no stack trace',
37+
err: util.inspect(err)
38+
};
39+
console.error(JSON.stringify(error));
40+
process.exit(1);
3341
}
3442
process.exit(0);
3543
}

0 commit comments

Comments
 (0)