question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Parser]: Custom LogLevels

See original GitHub issue

Feature Request

It would be great to overwrite the log levels.

Describe the solution you’d like

A way to overwrite the log levels for printing. The methods should stay the same, just the print would change.

Teachability, Documentation, Adoption, Migration Strategy

Example from Pino using nestjs-pino

return LoggerModule.forRootAsync({
    imports: [ConfigModule],
    useFactory: (configService: ConfigService<Configuration>) => {
      const severityLookup: Record<string, string> = {
        default: 'DEFAULT',
        silly: 'DEFAULT',
        verbose: 'DEBUG',
        debug: 'DEBUG',
        http: 'INFO',
        info: 'INFO',
        warn: 'WARNING',
        error: 'ERROR',
      };

      return {
        pinoHttp: {
          formatters: {
            level(label, number) {
              return { severity: severityLookup[label], level: number };
            },
          },
        },
      };
    },
    inject: [ConfigService],
  });

What is the motivation / use case for changing the behavior?

Some cloud providers require certain log levels for their log collectors to pick it up properly. See Googles log levels as an example.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jmcdo29commented, May 11, 2021

@ogma/logger 2.0.0 was released yesterday. This is included in functionality of it

1reaction
jmcdo29commented, May 4, 2021

I think I could make some sort of special or originalLevel property on the JSON work. I’d be concerned about it adding more clutter to the JSON, but usually devs aren’t looking at raw JSON anyways, so I don’t think it should be too big a deal. Maybe some sort of ool (Ogma original level) to keep the key short.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global Log Levels - LogViewPlus
In LogViewPlus, this is achieved by configuring parser specific Local Log Levels. Local log levels take precedence over global log levels.
Read more >
Process custom log levels - Grafana Loki
Hi, I'm starting with Loki in a docker environment. Logs are already transmitted to loki using the loki docker driver.
Read more >
Parse-server: Set logLevel - Stack Overflow
In the latest version of parse-server, the default logLevel seem to be "info", which logs all cloud code functions.
Read more >
LogLevel Enum (Microsoft.Extensions.Logging)
Learn how to implement a custom logging provider in your .NET applications. ILogger Interface (Microsoft.Extensions.Logging). Represents a type used to perform ...
Read more >
Support custom log levels for standard library logging module
Steps to reproduce: Configure a custom Python log level with logging.addLevelName and configure google-cloud-logging . · Code example.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found