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.

BunyanLogger extending built in Logger

See original GitHub issue

Looking to use the BunyanLogger in this context: https://docs.nestjs.com/techniques/logger#injecting-a-custom-logger

Where I can do setContext, which seems to be provided by the built in Logger. Could the BunyanLogger extend that to provide this, or is it more involved?

Looks like BunyanLogger takes a context as the second param to log, but in a class scenario it’s tedious to have to set that every time in the class.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lupu60commented, Apr 30, 2021

Hey @knownasilya. if you want to add more context in your logs. you can try using the extraFields arg.

    extraFields: {
        yourCustomContext:'ANY STRING',
        environment,
        version: packageBody.version,
      }

And inside of any service, you can use:

class MyService {
  private logger = new Logger(MyService.name);


  getData(args){
     this.logger.log("Heello") // here the log will have as context the Service name and all the extra fields.
  } 

}
0reactions
knownasilyacommented, May 14, 2021

Yes. I used it in the main directly and then I used it separately as a service.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wiredcraft/bunyan-logger - GitHub
Extend Bunyan to have default options and predefined streams etc. - GitHub - Wiredcraft/bunyan-logger: Extend Bunyan to have default options and predefined ...
Read more >
bunyan-logger - npm
Bunyan Logger. Build Status Coverage Status. Extend Bunyan to have default options and predefined streams etc.
Read more >
Wrapper over bunyan logging library - node.js - Stack Overflow
You can extend bunyan's functionality by creating a writeable stream : ... Create the bunyan logger */ const log = bunyan.
Read more >
Bunyan Logging With Production Troubleshooting in Mind
An object literal can be passed to the bunyan log methods, ... in case you are extending the native Error object with any...
Read more >
Class LoggingBunyan (4.2.1) | Node.js client library
This module provides support for streaming your Bunyan logs to [Stackdriver Logging](https://cloud.google.com/logging).
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