mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: 保存 renderer 日志到文件
This commit is contained in:
parent
d3089b8940
commit
4c625b172c
12 changed files with 61 additions and 31 deletions
|
|
@ -2,7 +2,7 @@ import { db, Tables } from './db'
|
|||
import type { FetchTracksResponse } from '../renderer/api/track'
|
||||
import { app } from 'electron'
|
||||
import { Request, Response } from 'express'
|
||||
import logger from './logger'
|
||||
import log from './log'
|
||||
import fs from 'fs'
|
||||
import * as musicMetadata from 'music-metadata'
|
||||
import { APIs } from './CacheAPIsName'
|
||||
|
|
@ -203,7 +203,7 @@ class Cache {
|
|||
if (api === APIs.SongDetail) {
|
||||
const cache = this.get(api, req.query)
|
||||
if (cache) {
|
||||
logger.debug(`[cache] Cache hit for ${req.path}`)
|
||||
log.debug(`[cache] Cache hit for ${req.path}`)
|
||||
return cache
|
||||
}
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ class Cache {
|
|||
)
|
||||
if (!isAudioFileExists) return
|
||||
|
||||
logger.debug(`[cache] Audio cache hit for ${req.path}`)
|
||||
log.debug(`[cache] Audio cache hit for ${req.path}`)
|
||||
|
||||
return {
|
||||
data: [
|
||||
|
|
@ -306,9 +306,9 @@ class Cache {
|
|||
|
||||
await fs.writeFile(`${path}/${id}-${br}.${type}`, buffer, error => {
|
||||
if (error) {
|
||||
return logger.error(`[cache] cacheAudio failed: ${error}`)
|
||||
return log.error(`[cache] cacheAudio failed: ${error}`)
|
||||
}
|
||||
logger.info(`Audio file ${id}-${br}.${type} cached!`)
|
||||
log.info(`Audio file ${id}-${br}.${type} cached!`)
|
||||
|
||||
db.upsert(Tables.Audio, {
|
||||
id,
|
||||
|
|
@ -318,7 +318,7 @@ class Cache {
|
|||
updateAt: Date.now(),
|
||||
})
|
||||
|
||||
logger.info(`[cache] cacheAudio ${id}-${br}.${type}`)
|
||||
log.info(`[cache] cacheAudio ${id}-${br}.${type}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue