0.1.10 • Published 3 years ago

axios-nice-log v0.1.10

Weekly downloads
237
License
MIT
Repository
github
Last release
3 years ago

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

OptionTypeDefaultdescription
prefixstring"axios"Line prefix
stylesobjectstyles defaulttemplate parts styles
templatestring"%prefix %time %method %url%params"line template parts available (%prefix %time %method %url %params)
templatesobjecttemplates defaulttemplate parts value %s - value replaced
loggercallbackconsole.loglogger 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: "=",
  }
0.1.10

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago