YesPlayMusic/packages/electron/log.ts

30 lines
2.1 KiB
TypeScript
Raw Normal View History

/** By default, it writes logs to the following locations:
* on Linux: ~/.config/{app name}/logs/{process type}.log
* on macOS: ~/Library/Logs/{app name}/{process type}.log
* on Windows: %USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log
* @see https://www.npmjs.com/package/electron-log
*/
2022-04-16 13:30:25 +08:00
import log from 'electron-log'
import pc from 'picocolors'
2022-03-13 14:40:38 +08:00
2022-04-16 13:30:25 +08:00
Object.assign(console, log.functions)
log.variables.process = 'main'
log.transports.console.format = `[{process}] ${pc.dim(
'{h}:{i}:{s}{scope}'
)} {level} {text}`
log.transports.file.level = 'info'
2022-03-13 14:40:38 +08:00
2022-04-16 13:30:25 +08:00
log.info(
`\n\n██╗ ██╗███████╗███████╗██████╗ ██╗ █████╗ ██╗ ██╗███╗ ███╗██╗ ██╗███████╗██╗ ██████╗
2022-03-13 14:40:38 +08:00
\n`
)
2022-04-16 13:30:25 +08:00
export default log
2022-04-02 00:45:20 +08:00
2022-04-16 13:30:25 +08:00
log.info(`[logger] logger initialized`)