axios-nice-log
v0.1.10
Published
Axios interceptor logger for requests query parameters
Downloads
28
Readme
axios-nice-log
Axios interceptor logger for requests query parameters for humans 😜
- many options customizable
- set global defaults
- styles by chalk
- lightweight ~2kb
Setup
npm i axios-nice-log
Usage
basic
import axios from 'axios'
import axiosNiceLog from 'axios-nice-log'
axios.interceptors.request.use(axiosNiceLog)
local option
import axios from 'axios'
import { axiosNiceLog, setAxiosNiceLog } from 'axios-nice-log'
// global options
setAxiosNiceLog({
prefix: 'my',
})
// local options
axios.interceptors.request.use((config) =>
axiosNiceLog(config, {
prefix: 'custom',
})
)
Api
Options
| Option | Type | Default | description | | ---------- | -------- | ----------------------------------- | -------------------------------------------------------------------------- | | prefix | string | "axios" | Line prefix | | styles | object | styles default | template parts styles | | template | string | "%prefix %time %method %url%params" | line template parts available (%prefix %time %method %url %params) | | templates | object | templates default | template parts value %s - value replaced | | logger | callback | console.log | logger function |
styles default
{
prefix: "green",
time: "reset",
method: "yellow",
url: "cyan",
params: "reset",
separator: "yellow",
delimiter: "gray",
}
templates default
{
prefix: "[%s]",
time: "%s",
method: "%s",
url: "%s",
params: "%s",
separator: "?",
delimiter: "=",
}