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.

Optional logging?

See original GitHub issue

When a request 404s superagent will say “Error: Not Found”, and isn’t kind enough to tell us what it didn’t find… In our applications we have had to copy/paste node-wpapi’s own transport API to add logging that tells us the URL of a request before it dispatches.

Ideally this could be option within the library itself, e.g. debug option that defaults to false and is picked up in transport methods like this:

function _httpGet( wpreq, callback, debug ) {
    if ( debug ) {
        console.log( '[node-wpapi] GET ' + wpreq.toString() );
    }
    
    checkMethodSupport( 'get', wpreq );
    // ...
}

Are you happy for me to put in a PR for this?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sdgluckcommented, Sep 3, 2018

@amitsarangi No, please go ahead!

1reaction
kadamwhitecommented, Feb 5, 2017

@sdgluck That’s a pretty good idea, I’d definitely be interested in adding this. I’d probably want to read the “debug” option off of the WPReq instance, so that it can be set for a full bound WPAPI instance or for a specific instantiated WPRequest; I’d also lean towards giving the transport itself a debug() method that can be injected so that users can self-select for console.log, or something like morgan that could integrate with their server logs, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle logging of null values in a Java Optional chain
Second, you shouldn't log null values. If you log null values, this means that you have issues similar to NullPointerExceptions , and that...
Read more >
(Optional) Logging web traffic - Amazon Simple Storage Service
An optional step to configure web traffic logging for your static website.
Read more >
Optional Logging Parameters for Static Content Generation
Optional Logging Parameters for Static Content Generation ... 20 = verbose (logs each page processed with a timestamp for how long it took...
Read more >
logging — Logging facility for Python — Python 3.11.1 ...
The second optional keyword argument is stack_info, which defaults to False . If true, stack information is added to the logging message, including...
Read more >
Python best practice when logging optional arguments
I have a method that accepts one or more optional arguments and I'd like to log them, following the best practice of lazy...
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