Skip to content

Optional logging? #295

@sdgluck

Description

@sdgluck

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions