How to use the electron-log.create function in electron-log

To help you get started, we’ve selected a few electron-log examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lanten / electron-antd / app / core / tools / log / system-logger.ts View on Github external
constructor(logId: string) {
    this.logId = logId
    this.logFileName = `${formatDate('YYYY-MM')}.log`
    this.logger = electronLog.create(logId)

    this.logger.transports.file.resolvePath = () => {
      return path.resolve(LOGS_PATH, this.logFileName)
    }

    const isDev = process.env.NODE_ENV === 'development' ? ' [dev]' : ''

    this.logger.transports.file.format = `[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]${isDev} {text}`
    this.logger.transports.console.format = '[{level}] {text}'
  }