fix: log is not generated after clear log from setting (#2732)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-04-15 22:53:04 +07:00 committed by GitHub
parent 49401bd8eb
commit 889d374fad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -32,7 +32,6 @@ export enum AppRoute {
startServer = 'startServer',
stopServer = 'stopServer',
log = 'log',
logServer = 'logServer',
systemInformation = 'systemInformation',
showToast = 'showToast',
}

View File

@ -126,6 +126,10 @@ export class FileLogger extends Logger {
const writeLog = (message: string, logPath: string) => {
if (!fs.existsSync(logPath)) {
const logDirectory = path.join(getJanDataFolderPath(), 'logs')
if (!fs.existsSync(logDirectory)) {
fs.mkdirSync(logDirectory)
}
fs.writeFileSync(logPath, message)
} else {
const logFile = fs.createWriteStream(logPath, {