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.
26 lines
610 B
26 lines
610 B
2 years ago
|
import pino from 'pino';
|
||
|
import pinoPretty from 'pino-pretty';
|
||
|
import path from 'path';
|
||
|
|
||
|
const log_level = process.env.PROD === undefined ? "debug" : "info";
|
||
|
|
||
|
export const log = pino({
|
||
|
level: log_level,
|
||
|
prettyPrint: {
|
||
|
levelFirst: true,
|
||
|
colorize: true,
|
||
|
singleLine: true,
|
||
|
ignore: "module",
|
||
|
messageFormat: "{levelLabel}[{pid}] {module}: {msg}"
|
||
|
},
|
||
|
prettifier: pinoPretty
|
||
|
});
|
||
|
|
||
|
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 };
|