Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use this #64

Open
zhex900 opened this issue Jul 13, 2021 · 1 comment
Open

How do I use this #64

zhex900 opened this issue Jul 13, 2021 · 1 comment

Comments

@zhex900
Copy link

zhex900 commented Jul 13, 2021

Hi,

How do I use this module? I can't make much sense from the doc. This is my logger setup. Right now, I only can see the error message in the console. But stack trace is not there.

const applyServiceStyles = (log: LogDescriptor, messageKey: string) => {
  let style;
  switch (log.service) {
    case SERVICES.KIOSK_APP_CLIENT:
      style = bgLightBlue;
      break;
    case SERVICES.KIOSK_APP_SERVER:
      style = bgYellow;
      break;
    case SERVICES.AWS_IOT_SERVER:
      style = bgLightGreen;
      break;
    case SERVICES.AWS_IOT:
      style = bgLightMagenta;
      break;
    default:
      style = bgLightCyan;
      break;
  }
  return `${black(style(`[${log.service}]`))} ${log[messageKey]}`;
};

const logger = pino({
  prettyPrint: {
    colorize: true,
    errorLikeObjectKeys: ["err", "error", "details"],
    levelFirst: true,
    translateTime: "SYS:hh:MM:ss TT dd-mm-yyyy",
    ignore: "pid,hostname,service",
    messageFormat: (log, messageKey, levelLabel) => {
      return applyServiceStyles(log, messageKey);
    },
  },
  level: process.env.LOG_LEVEL || "debug",
  serializers: {
    error: pino.stdSerializers.err,
  },
});
@mcollina
Copy link
Member

Can you add a full example to reproduce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants