1 Commits
Author SHA1 Message Date
sugoidogo 02ff1b58f7 try to fix logging again
Main / release (push) Successful in 41s
2026-01-14 00:57:44 -08:00
+12 -8
View File
@@ -4,22 +4,26 @@ import { program } from "commander"
import { parseJSON, parseTOML, stringifyJSON } from "confbox"
import fs from "node:fs"
import path from "node:path"
import util from 'node:util'
import strftime from 'strftime'
import { spawnSync } from "node:child_process"
const logfd = fs.openSync('/etc/snapback/log.txt', 'w')
let logfd = 1
function logToFile() {
// Source - https://stackoverflow.com/a/35542360
// Posted by Anatol - user3173842
// Source - https://stackoverflow.com/a
// Posted by Clément Désiles, modified by community. See post 'Timeline' for change history
// Retrieved 2026-01-14, License - CC BY-SA 3.0
var access = fs.createWriteStream('',{'fd':logfd});
process.stdout.write = process.stderr.write = access.write.bind(access);
logfd = fs.openSync('/etc/snapback/log.txt','w')
const logFile = fs.createWriteStream('', { 'fd':logfd });
const logStdout = process.stdout;
process.on('uncaughtException', function (err) {
console.error((err && err.stack) ? err.stack : err);
});
console.log = function (...args) {
logFile.write(util.format.apply(null, args) + '\n');
logStdout.write(util.format.apply(null, args) + '\n');
}
console.error = console.log;
}
let config: { [key: string]: string|undefined } = {}