log messages now contain script context if available

This commit is contained in:
zadam
2022-02-01 22:25:38 +01:00
parent 6833959f3b
commit 0917fc8be1
4 changed files with 13 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
const fs = require('fs');
const dataDir = require('./data_dir');
const cls = require('./cls');
if (!fs.existsSync(dataDir.LOG_DIR)) {
fs.mkdirSync(dataDir.LOG_DIR, 0o700);
@@ -49,6 +50,12 @@ function checkDate(millisSinceMidnight) {
}
function log(str) {
const bundleNoteId = cls.get("bundleNoteId");
if (bundleNoteId) {
str = `[Script ${bundleNoteId}] ${str}`;
}
let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
millisSinceMidnight = checkDate(millisSinceMidnight);