GithubHelp home page GithubHelp logo

gerhut / axios-debug-log Goto Github PK

View Code? Open in Web Editor NEW
131.0 4.0 10.0 94 KB

Axios interceptor of logging request & response with debug library.

Home Page: https://npm.im/axios-debug-log

License: BSD 3-Clause "New" or "Revised" License

JavaScript 92.36% TypeScript 7.64%
axios debug logging

axios-debug-log's Introduction

axios-debug-log

Node.js CI Coverage Status JavaScript Style Guide

Axios interceptor of logging requests & responses by debug.

Screenshot

Install

$ npm install --save axios axios-debug-log

Node.js usage

  1. Install: add require('axios-debug-log') before any axios execution.
  2. Enable: set DEBUG=axios environment variables before start your fantastic Node.js application.

Or

Add require('axios-debug-log/enable') before any axios execution to install and enable.

Or

Run DEBUG=axios node --require axios-debug-log [entrypoint.js]

Or

Run node --require axios-debug-log/enable [entrypoint.js]

OR

  1. Install: add when using ES modules (type: module) before any axios execution.
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
require('axios-debug-log');
const axios = require('axios');
  1. Enable: set DEBUG=axios environment variables before start your fantastic Node.js application.

Browser usage

  1. Install: add require('axios-debug-log') before any axios execution.
  2. Enable: set localStorage.debug = "axios" before start your fantastic web application.

Or

Add require('axios-debug-log/enable') before any axios execution to install and enable.

Please read README of debug for usage details.

Configuration

// Log content type
require('axios-debug-log')({
  request: function (debug, config) {
    debug('Request with ' + config.headers['content-type'])
  },
  response: function (debug, response) {
    debug(
      'Response with ' + response.headers['content-type'],
      'from ' + response.config.url
    )
  },
  error: function (debug, error) {
    // Read https://www.npmjs.com/package/axios#handling-errors for more info
    debug('Boom', error)
  }
})

Customization

Use require('axios-debug-log').addLogger(instance, debug) to add custom debug logger to custom instance.

var github = axios.create({ baseURL: 'https://api.github.com/' })
var githubLogger = require('debug')('github')
require('axios-debug-log').addLogger(github, githubLogger)
github('/user')

Trust by

octokit SlackAPI Center for Public Integrity AppImage pytorch

And Yours...

License

MIT

axios-debug-log's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar gerhut avatar greenkeeper[bot] avatar ilyasemenov avatar julienpradet avatar vikzh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

axios-debug-log's Issues

Configurable logging

Hi! Thanks for this new easy to use debugging tool!
I think it would be possible to configure logging, for example, to see sent post params.

An in-range update of mocha is breaking the build 🚨

The devDependency mocha was updated from 6.0.2 to 6.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • βœ… coverage/coveralls: First build on greenkeeper/mocha-6.1.0 at 100.0% (Details).

Release Notes for v6.1.0

6.1.0 / 2019-04-07

πŸ”’ Security Fixes

  • #3845: Update dependency "js-yaml" to v3.13.0 per npm security advisory (@plroebuck)

πŸŽ‰ Enhancements

  • #3766: Make reporter constructor support optional options parameter (@plroebuck)
  • #3760: Add support for config files with .jsonc extension (@sstephant)

πŸ“  Deprecations

These are soft-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha:

πŸ› Fixes

  • #3829: Use cwd-relative pathname to load config file (@plroebuck)
  • #3745: Fix async calls of this.skip() in "before each" hooks (@juergba)
  • #3669: Enable --allow-uncaught for uncaught exceptions thrown inside hooks (@givanse)

and some regressions:

πŸ“– Documentation

πŸ”© Other

  • #3830: Replace dependency "findup-sync" with "find-up" for faster startup (@cspotcode)
  • #3799: Update devDependencies to fix many npm vulnerabilities (@XhmikosR)
Commits

The new version differs by 28 commits.

  • f4fc95a Release v6.1.0
  • bd29dbd update CHANGELOG for v6.1.0 [ci skip]
  • aaf2b72 Use cwd-relative pathname to load config file (#3829)
  • b079d24 upgrade deps as per npm audit fix; closes #3854
  • e87c689 Deprecate this.skip() for "after all" hooks (#3719)
  • 81cfa90 Copy Suite property "root" when cloning; closes #3847 (#3848)
  • 8aa2fc4 Fix issue 3714, hide pound icon showing on hover header on docs page (#3850)
  • 586bf78 Update JS-YAML to address security issue (#3845)
  • d1024a3 Update doc examples "tests.html" (#3811)
  • 1d570e0 Delete "/docs/example/chai.js"
  • ade8b90 runner.js: "self.test" undefined in Browser (#3835)
  • 0098147 Replace findup-sync with find-up for faster startup (#3830)
  • d5ba121 Remove "package" flag from sample config file because it can only be passes as CLI arg (#3793)
  • a3089ad update package-lock
  • 75430ec Upgrade yargs-parser dependency to avoid loading 2 copies of yargs

There are 28 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

replaceLogger

Hi,

thanks for this great tool. I've got a small issue with it, however. By default, debug logs to stderr, which makes for rather nasty console.error messages:

image

I can use a custom logger that logs to console.info like this:

const axiosLogger = require('debug')('axios');
axiosLogger.log = console.info.bind(console);
require('axios-debug-log').addLogger(apiClient, axiosLogger);

Unfortunately, this results in duplicate logging messages - the ones sent to stderr (the default logger) and my custom logger.

I'd love a way to only use my custom logger.

@types/debug as a devDependency

Currently, in package.json...

  "dependencies": {
    "@types/debug": "^4.0.0",
    "debug": "^4.0.0"
  },

Is @types/debug a needed dependency, or could be moved to devDependencies ?

Having it in dependencies causes @types/debug to be installed in production builds, and the package is just typescript typings that are not needed in runtime

Not working with `[email protected]`

package.json

{
    "name": "MyApp",
    "dependencies": {
        "axios": "1.0.0",
        "axios-debug-log": "0.8.4"
    }
}

output.log

node:internal/modules/cjs/loader:499
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/helpers/isAbsoluteURL' is not defined by "exports" in /myapp/node_modules/axios/package.json
    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:748:3)
    at resolveExports (node:internal/modules/cjs/loader:493:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/myapp/node_modules/axios-debug-log/index.js:4:21) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' 

Import instead of require

Hi,

How can I use import instead of require?
Or how can I use require within the context of imports?

My axios code is like so:

import axios from "axios";
const instance = axios.create(config);
let result = instance.axios.get('pings')

An in-range update of sinon is breaking the build 🚨

Version 2.3.4 of sinon just got published.

Branch Build failing 🚨
Dependency sinon
Current Version 2.3.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As sinon is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ coverage/coveralls Coverage pending from Coveralls.io Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Make sandbox.resetHistory also reset spies
  • Fix #1372: make sandbox.resetHistory also reset spies (#1424)
Commits

The new version differs by 5 commits.

  • 72ae300 Update docs/changelog.md and set new release id in docs/_config.yml
  • 769d770 Add release documentation for v2.3.4
  • c8d2ec0 2.3.4
  • d27976a Update Changelog.txt and AUTHORS for new release
  • 330101a Fix #1372: make sandbox.resetHistory also reset spies (#1424)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of sinon is breaking the build 🚨

Version 2.3.3 of sinon just got published.

Branch Build failing 🚨
Dependency sinon
Current Version 2.3.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As sinon is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
  • βœ… coverage/coveralls First build on greenkeeper/sinon-2.3.3 at 100.0% Details

Release Notes Make stubbing of static function properties possible
  • Fix #1450, make stubbing of static function properties possible
Commits

The new version differs by 24 commits.

  • bade318 Update docs/changelog.md and set new release id in docs/_config.yml
  • 65d4e88 Add release documentation for v2.3.3
  • 2204e72 2.3.3
  • 64034ee Update Changelog.txt and AUTHORS for new release
  • 1ece07c Merge pull request #1450 from raulmatei/fix-1445-sandbox-stubbing-static-function-property-throws-error
  • 452981c Fix 1445: make stubbing of static function properties possible
  • 25f3eeb Update sandbox configuration docs. (#1443)
  • c76fa2e Merge pull request #1444 from piperchester/patch-1
  • 6539d94 Update README.md
  • c6d01d8 Add missing function name (#1440)
  • 5f989a8 Remove confusing .withArgs from spy documentation (#1438)
  • 9ca272e Remove superfluous calls in example (#1437)
  • 9e3eac3 Merge pull request #1436 from sinonjs/feature-detect-name-property
  • 65d3d7b Feature detect function name property in issue 950
  • e0c75bd Add test for #950, show that it has been fixed (#1435)

There are 24 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

No response from calls

Hi, I installed your debug tool to try and figure out why an API call wasn't working within my project. I'm using

const data = await axios({
stuff here
};

But not getting any response info, just the calls themselves? (URLs removed). Any help would be greatly appreciated
Screenshot 2020-12-31 at 13 01 36

An in-range update of axios is breaking the build 🚨

The devDependency axios was updated from 0.18.0 to 0.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

axios is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • βœ… coverage/coveralls: First build on greenkeeper/axios-0.19.0 at 100.0% (Details).

Release Notes for v0.19.0

Fixes and Functionality:

  • Unzip response body only for statuses != 204 (#1129) - drawski
  • Destroy stream on exceeding maxContentLength (fixes #1098) (#1485) - Gadzhi Gadzhiev
  • Makes Axios error generic to use AxiosResponse (#1738) - Suman Lama
  • Fixing Mocha tests by locking follow-redirects version to 1.5.10 (#1993) - grumblerchester
  • Allow uppercase methods in typings. (#1781) - Ken Powers
  • Fixing .eslintrc without extension (#1789) - Manoel
  • Consistent coding style (#1787) - Ali Servet Donmez
  • Fixing building url with hash mark (#1771) - Anatoly Ryabov
  • This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after #, because client cut everything after #
  • Preserve HTTP method when following redirect (#1758) - Rikki Gibson
  • Add getUri signature to TypeScript definition. (#1736) - Alexander Trauzzi
  • Adding isAxiosError flag to errors thrown by axios (#1419) - Ayush Gupta
  • Fix failing SauceLabs tests by updating configuration - Emily Morehouse

Documentation:

  • Add information about auth parameter to README (#2166) - xlaguna
  • Add DELETE to list of methods that allow data as a config option (#2169) - Daniela Borges Matos de Carvalho
  • Update ECOSYSTEM.md - Add Axios Endpoints (#2176) - Renan
  • Add r2curl in ECOSYSTEM (#2141) - 유용우 / CX
  • Update README.md - Add instructions for installing with yarn (#2036) - Victor Hermes
  • Fixing spacing for README.md (#2066) - Josh McCarty
  • Update README.md. - Change .then to .finally in example code (#2090) - Omar Cai
  • Clarify what values responseType can have in Node (#2121) - Tyler Breisacher
  • docs(ECOSYSTEM): add axios-api-versioning (#2020) - Weffe
  • It seems that responseType: 'blob' doesn't actually work in Node (when I tried using it, response.data was a string, not a Blob, since Node doesn't have Blobs), so this clarifies that this option should only be used in the browser
  • Add issue templates - Emily Morehouse
  • Update README.md. - Add Querystring library note (#1896) - Dmitriy Eroshenko
  • Add react-hooks-axios to Libraries section of ECOSYSTEM.md (#1925) - Cody Chan
  • Clarify in README that default timeout is 0 (no timeout) (#1750) - Ben Standefer
Commits

The new version differs by 108 commits.

  • 8d0b92b Releasing 0.19.0
  • 3f7451c Update Changelog for release (0.19.0)
  • f28ff93 Add information about auth parameter to README (#2166)
  • 5250e6e Add DELETE to list of methods that allow data as a config option (#2169)
  • 6b0ccd1 Update ECOSYSTEM.md - Add Axios Endpoints (#2176)
  • 299e827 Add r2curl in ECOSYSTEM (#2141)
  • fd0c959 Unzip response body only for statuses != 204 (#1129)
  • 92d2313 Update README.md - Add instructions for installing with yarn (#2036)
  • ddcc2e4 Fixing spacing for README.md (#2066)
  • 48c43d5 Update README.md. - Change .then to .finally in example code (#2090)
  • b7a9744 Clarify what values responseType can have in Node (#2121)
  • 0d4fca0 Destroy stream on exceeding maxContentLength (fixes #1098) (#1485)
  • 047501f Makes Axios error generic to use AxiosResponse (#1738)
  • 283d7b3 docs(ECOSYSTEM): add axios-api-versioning (#2020)
  • 2eeb59a Fixing Mocha tests by locking follow-redirects version to 1.5.10 (#1993)

There are 108 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of sinon is breaking the build 🚨

Version 5.0.9 of sinon was just published.

Branch Build failing 🚨
Dependency sinon
Current Version 5.0.8
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

sinon is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
  • βœ… coverage/coveralls First build on greenkeeper/sinon-5.0.9 at 100.0% Details

Commits

The new version differs by 5 commits.

  • 86b930c Update docs/changelog.md and set new release id in docs/_config.yml
  • 033aa60 Add release documentation for v5.0.9
  • 3321085 5.0.9
  • 9f321d5 Update History.md and AUTHORS for new release
  • e862196 Upgrade @std/esm to esm.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of standard is breaking the build 🚨

Version 12.0.1 of standard was just published.

Branch Build failing 🚨
Dependency standard
Current Version 12.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • βœ… coverage/coveralls: First build on greenkeeper/standard-12.0.1 at 100.0% (Details).

Commits

The new version differs by 8 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

[email protected] not compatible with unejected CRAv5

To save anyone else the headache of figuring this out, Axios changed something with how they export the main module and its not compatible with the non-ejected CRA, and as CRA is deprecated at this point it likely never will be.

facebook/create-react-app#12605
facebook/create-react-app#12021

Problem is the var axios = require('axios') returns a string like /static/media/axios.5036f7f7333f291ef6b3.cjs not the actual package, so you get this error when trying to import axios-debug-log:
Uncaught TypeError: Cannot read properties of undefined (reading 'request') at addLogger

Apparently you can run CRACO to get around this

I was able to get it running by copying over index.js and switching to an import statement

An in-range update of sinon is breaking the build 🚨

Version 4.1.4 of sinon was just published.

Branch Build failing 🚨
Dependency sinon
Current Version 4.1.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

sinon is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ coverage/coveralls Coverage pending from Coveralls.io Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes Minor fix for Symbol names and deprecation of spy.reset
  • Fix: assertion error messages did not handle Symbol names (#1640)
  • Deprecate spy.reset(), use spy.resetHistory() instead (#1446)
Commits

The new version differs by 36 commits.

  • 1ea2749 Update docs/changelog.md and set new release id in docs/_config.yml
  • 078c082 Add release documentation for v4.1.4
  • 571263e 4.1.4
  • f2ee9f1 Update History.md and AUTHORS for new release
  • a8262dd Assertion error messages handle symbolic method names
  • 8fa1e14 Merge pull request #1641 from mroderick/point-to-stack-overflow
  • 7c1ebd0 Update issue links to point to sinonjs/sinon
  • 93418f6 Update documentation to emphasize Stack Overflow
  • ca9e2fa Merge pull request #1636 from fearphage/fix-headless-chrome-in-circle
  • 39186f4 use google-chrome-unstable for tests
  • 6315621 invalidate cache
  • d078af9 try using default chrome install
  • 177c4b6 upgraded to the lastest official version of mochify
  • ecdc4e0 test with updated mochify
  • 360c2e7 added more details and notes

There are 36 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Allow injecting axios manually

I have a previously created instance of axios so I can't use this at the moment. Maybe you could change it to work like so:

// Use explicitly declared axios
require('axios-debug-log')(axios);

An in-range update of axios is breaking the build 🚨

Version 0.16.2 of axios just got published.

Branch Build failing 🚨
Dependency axios
Current Version 0.16.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As axios is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ coverage/coveralls Coverage pending from Coveralls.io Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 12 commits.

  • 46e275c Releasing 0.16.2
  • e040815 Updating Changelog
  • 3579da4 Merge pull request #930 from luciy/master
  • e4e3212 Convert the method parameter to lowercase
  • d1278df Merge pull request #887 from fgnass/no-buffer-in-browser
  • 1beb245 Fixing typo in comment blocks of createError() and enhanceError() functions (#857)
  • c849467 use Buffer global in http.js
  • c82753c Use is-buffer instead of Buffer.isBuffer
  • f31317a Merge pull request #830 from mzabriskie/feature/include-request-in-errors
  • 1e76ea3 Adding documentation for error.request
  • 22ce6db Adding request to error objects when it is available
  • e0d59eb Adding failing tests that verify errors contain the request

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.