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.

Best practices for scoped logging

See original GitHub issue

Hi Probot friends!

I’m working on a bot that reacts to pull request events. For debugging purposes, I’d like to be able to tail Probot’s logs and grep for log lines that pertain to just that PR:

heroku logs -t | grep pr-123

At present, I’m thinking of creating a custom logging function in the scope of the event handler:

async function handler (context) {
  function log (args) {
    const prefix = `pr-${context.payload.pull_request.number}`
    context.log(prefix, ...args)
  }

  log('some', objects, and, stuff)
})

Is there a better built-in way to includ grep-friendly context when logging?

cc @sarahs

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, May 3, 2019

Issue-Label Bot is automatically applying the label question ❓ to this issue, with a confidence of 0.83. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

0reactions
gr2mcommented, Dec 8, 2020

Probot is using pino internally now, all instances should have the .child() method, see https://getpino.io/#/?id=usage

<div>Pino - Super fast, all natural JSON logger for Node.js</div><div>Super fast, all natural JSON logger for Node.js</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add logging for a scoped application? - ServiceNow
Best practice for scoped applications is to create two system properties to control the destination of verbosity of logging.
Read more >
Logging with ILogger in .NET: Recommendations and best ...
This article describes recommendations and best practices for using the ILogger based logging system which has been introduced with .
Read more >
Logging for Scoped Applications - ServiceNow Elite
How to use log statements with scoped applications. ... The good news is that you can use these alternative log statements instead.
Read more >
How to improve Serilog logging in .NET 6 by using Scopes
Finally, two must-read articles about logging best practices. The first one is by Thiago Nascimento Figueiredo: Logs - Why, good practices, ...
Read more >
OAuth Scopes Best Practices | Curity
If not designed carefully, you can end up with a large number of scopes that are difficult to maintain over time. The most...
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