Skip to content

Commit bb4ac56

Browse files
add more logs and timestamps for printed logs (#17)
1 parent c52defe commit bb4ac56

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ const cflogs = require('cf-logs');
55

66
const loggerOptions = {
77
filePath: path.join(__dirname, '../logs', 'logs.log'),
8-
console: process.env.LOG_TO_CONSOLE || false
8+
console: process.env.LOG_TO_CONSOLE || false,
9+
consoleOptions: {
10+
timestamp() {
11+
return new Date().toISOString();
12+
}
13+
}
914
};
1015
cflogs.init(loggerOptions);
1116

lib/logger.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ class Logger {
201201
let stepLogger = this.steps[stepName];
202202
if (!stepLogger) {
203203
stepLogger = this.taskLogger.create(stepName, undefined, undefined, runCreationLogic);
204+
logger.info(`Created new step logger for container: ${containerId}`);
204205
try {
205206
await stepLogger.restore(); // jshint ignore:line
207+
logger.info(`Restored step logger state for container: ${containerId}`);
206208
} catch (err) {
207209
const error = new CFError({
208210
cause: err,
@@ -211,6 +213,8 @@ class Logger {
211213
logger.error(error.toString());
212214
return;
213215
}
216+
} else {
217+
logger.info(`Reusing step logger for container: ${containerId}`);
214218
}
215219

216220
const logSizeLimit = receivedLogSizeLimit ? (parseInt(receivedLogSizeLimit) * 1000000) : undefined;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dependencies": {
99
"@codefresh-io/task-logger": "^0.0.3",
1010
"cf-errors": "^0.1.11",
11-
"cf-logs": "git+https://github.com/codefresh-io/cf-logs.git#ceba4f309e52a077747a0c6bf9c3ad02e762dc4b",
11+
"cf-logs": "^1.1.0",
1212
"docker-events": "0.0.2",
1313
"dockerode": "^2.3.0",
1414
"forever": "^0.15.3",

yarn.lock

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,13 @@ cf-errors@^0.1.11:
552552
dependencies:
553553
lodash "4.15.0"
554554

555-
"cf-logs@git+https://github.com/codefresh-io/cf-logs.git#ceba4f309e52a077747a0c6bf9c3ad02e762dc4b":
556-
version "0.0.3"
557-
resolved "git+https://github.com/codefresh-io/cf-logs.git#ceba4f309e52a077747a0c6bf9c3ad02e762dc4b"
555+
cf-logs@^1.1.0:
556+
version "1.1.0"
557+
resolved "https://registry.yarnpkg.com/cf-logs/-/cf-logs-1.1.0.tgz#2ea2dae43c71a2a06579b82a287a4d91a86db3f5"
558+
integrity sha512-dUcIw2K6PjHouhaiTbJTSN2iPoja+diS0vTcv3+ENcq9o1Ow2AziYAWqYW0MtUJxrdKDiowyZxIQvJ54cCBPTA==
558559
dependencies:
559560
lodash "^3.10.1"
561+
q "^1.5.1"
560562
winston "2.1.1"
561563
winston-loggly "1.2.0"
562564

@@ -3593,6 +3595,11 @@ q@^1.4.1:
35933595
version "1.5.0"
35943596
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"
35953597

3598+
q@^1.5.1:
3599+
version "1.5.1"
3600+
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
3601+
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
3602+
35963603
qs@~5.2.0:
35973604
version "5.2.1"
35983605
resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc"

0 commit comments

Comments
 (0)