UNPKG

@kikiutils/node

Version:

A modular utility library for Node.js offering secure hashing, flexible logging, datetime manipulation, and more.

36 lines (32 loc) 1.09 kB
'use strict'; const consola = require('consola'); /** * A consola logger instance. * * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables. * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`, * the level will be set to `0`. * * To manually change the level, assign the desired level to `logger.level`. * * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level). * * @example * ```typescript * import logger from '@kikiutils/node/consola'; * * logger.info('test'); // ℹ test 3:56:30 AM * * // Manually change the level * logger.level = 3; * ``` */ const consolaLogger = consola.createConsola(); const logger = consolaLogger; if (process.env.CONSOLA_LOGGER_LEVEL !== undefined) consolaLogger.level = +process.env.CONSOLA_LOGGER_LEVEL; else consolaLogger.level = process.env.NODE_ENV === 'production' ? 0 : consolaLogger.level; exports.consolaLogger = consolaLogger; exports.logger = logger; //# sourceMappingURL=consola.cjs.map