How to use the consola.create function in consola

To help you get started, we’ve selected a few consola 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 nuxt / fabula / src / logging.js View on Github external
addLogger(logger, loggerInfo) {
    const path = loggerInfo.path || loggerInfo
    const stream = createWriteStream(path, { flags: 'a' })
    const reporters = [new Reporter(stream, loggerInfo.reporter)]
    this.loggers[logger] = consola.create(({ reporters }))
    return this.loggers[logger]
  }
  // Returns a logger by name
github twitch-js / twitch-js / src / utils / logger / create.js View on Github external
const createLogger = ({ scope, ...options } = {}) => {
  const label = ['twitch-js'].concat(scope || []).join('/')

  const logger = consola.create(options).withScope(label)

  logger.startTimer = startProps => {
    const now = new Date()

    if (startProps && startProps.message) {
      logger.info(startProps)
    }

    return {
      done: doneProps => {
        const elapsed = new Date() - now
        logger.success({ message: `${doneProps.message} (${elapsed}ms)` })
      },
    }
  }