UNPKG

zrw-log

Version:

日志插件

28 lines (27 loc) 861 B
const log = require("electron-log"); const getDT = ()=>{ const currentDate = new Date(); const year = currentDate.getFullYear(); const month = String(currentDate.getMonth() + 1).padStart(2, '0'); const day = String(currentDate.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; }; function wLog(path, logData, type = 'info') { log.transports.file.resolvePathFn = ()=>`${process.cwd()}/logs/${path}/${getDT()}.log`; if (type === 'info') { log.info(logData); } else if (type === 'warn') { log.warn(logData); } else if (type === 'error') { log.error(logData); } else if (type === 'verbose') { log.verbose(logData); } else if (type === 'debug') { log.debug(logData); } else if (type === 'silly') { log.silly(logData); } } module.exports = { wLog };