This is only for testing npm init for installing other things. https://learnjsthehardway.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ljsthw-bandolier/lib/logging.js

32 lines
713 B

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 };