fix: should check app dir before spawning log (#1297)

This commit is contained in:
Louis 2024-01-03 00:10:50 +07:00 committed by GitHub
parent 1392da7cd4
commit 162fa48c63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,12 +3,16 @@ import util from 'util'
import path from 'path'
import os from 'os'
export const logPath = path.join(os.homedir(), 'jan', 'app.log')
const appDir = path.join(os.homedir(), 'jan')
export const logPath = path.join(appDir, 'app.log')
export const log = function (d: any) {
if (fs.existsSync(appDir)) {
var log_file = fs.createWriteStream(logPath, {
flags: 'a',
})
export const log = function (d: any) {
log_file.write(util.format(d) + '\n')
log_file.close()
}
}