import pino from 'pino'; import pinoPretty from 'pino-pretty'; import path from 'path'; const log_level = process.env.PROD === undefined ? "debug" : "info"; const pino_config = { level: log_level, } if(!process.env.PROD) { pino_config.transport = { target: 'pino-pretty', options: { levelFirst: true, colorize: true, singleLine: true, ignore: "module", messageFormat: "{levelLabel}[{pid}] {module}: {msg}" } } } export const log = pino(pino_config); export const create = (import_url) => { const pd = path.parse(import_url); const log_line = `${path.basename(pd.dir)}/${pd.base}`; return log.child({module: log_line}); } export default { create, log };