2022-04-05 23:02:59 +08:00
|
|
|
|
/** 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-03-13 14:40:38 +08:00
|
|
|
|
import logger from 'electron-log'
|
2022-03-29 16:52:53 +08:00
|
|
|
|
import pc from 'picocolors'
|
2022-03-13 14:40:38 +08:00
|
|
|
|
|
2022-04-02 00:45:20 +08:00
|
|
|
|
Object.assign(console, logger.functions)
|
2022-03-29 16:52:53 +08:00
|
|
|
|
logger.transports.console.format = `${pc.dim('{h}:{i}:{s}{scope}')} › {text}`
|
2022-04-05 23:02:59 +08:00
|
|
|
|
logger.transports.file.level = 'info'
|
2022-03-13 14:40:38 +08:00
|
|
|
|
|
|
|
|
|
logger.info(
|
2022-03-29 16:52:53 +08:00
|
|
|
|
`\n\n██╗ ██╗███████╗███████╗██████╗ ██╗ █████╗ ██╗ ██╗███╗ ███╗██╗ ██╗███████╗██╗ ██████╗
|
2022-03-13 14:40:38 +08:00
|
|
|
|
╚██╗ ██╔╝██╔════╝██╔════╝██╔══██╗██║ ██╔══██╗╚██╗ ██╔╝████╗ ████║██║ ██║██╔════╝██║██╔════╝
|
|
|
|
|
╚████╔╝ █████╗ ███████╗██████╔╝██║ ███████║ ╚████╔╝ ██╔████╔██║██║ ██║███████╗██║██║
|
|
|
|
|
╚██╔╝ ██╔══╝ ╚════██║██╔═══╝ ██║ ██╔══██║ ╚██╔╝ ██║╚██╔╝██║██║ ██║╚════██║██║██║
|
|
|
|
|
██║ ███████╗███████║██║ ███████╗██║ ██║ ██║ ██║ ╚═╝ ██║╚██████╔╝███████║██║╚██████╗
|
|
|
|
|
╚═╝ ╚══════╝╚══════╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝\n`
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
export default logger
|
2022-04-02 00:45:20 +08:00
|
|
|
|
|
|
|
|
|
logger.info(`[logger] logger initialized`)
|