Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)` })
},
}
}