fix log.txt with json objects
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Oct 10, 2024 at 18:34 UTC
ea8e1b107688e5bbcd7e209bdd5708f81fb7da0e
1 file changed
+2
-1
meshcentral.js
+2
-1
@@ -3858,7 +3858,8 @@ function CreateMeshCentralServer(config, args) {
3858
if (obj.xxLogFile != null) {
3859
try {
3860
if (obj.xxLogDateStr != d.toLocaleDateString()) { obj.xxLogDateStr = d.toLocaleDateString(); obj.fs.writeSync(obj.xxLogFile, '---- ' + d.toLocaleDateString() + ' ----\r\n'); }
3861
- obj.fs.writeSync(obj.xxLogFile, new Date().toLocaleTimeString() + ' - ' + source + ': ' + args.join(', ') + '\r\n');
3861
+ const formattedArgs = args.map(function (arg) { return (typeof arg === 'object' && arg !== null) ? JSON.stringify(arg) : arg; });
3862
+ obj.fs.writeSync(obj.xxLogFile, new Date().toLocaleTimeString() + ' - ' + source + ': ' + formattedArgs.join(', ') + '\r\n');
3863
} catch (ex) { }
3864
}
3865
}