{"id":15632561,"url":"https://github.com/hg-pyun/axios-logger","last_synced_at":"2025-05-16T18:06:54.098Z","repository":{"id":32549902,"uuid":"136154123","full_name":"hg-pyun/axios-logger","owner":"hg-pyun","description":"Beautify Axios Logging Messages","archived":false,"fork":false,"pushed_at":"2024-09-11T22:01:10.000Z","size":941,"stargazers_count":177,"open_issues_count":18,"forks_count":32,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-16T18:06:53.220Z","etag":null,"topics":["axios","javascript","logger","nodejs","pretty"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hg-pyun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-05T09:33:47.000Z","updated_at":"2025-04-23T08:51:44.000Z","dependencies_parsed_at":"2024-03-14T02:26:02.391Z","dependency_job_id":"cf5bc7db-2ebc-42f2-826f-f698795b07e3","html_url":"https://github.com/hg-pyun/axios-logger","commit_stats":{"total_commits":108,"total_committers":12,"mean_commits":9.0,"dds":"0.39814814814814814","last_synced_commit":"1cac599487fa127042abdb1836f31d4cd5686973"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Faxios-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Faxios-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Faxios-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Faxios-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hg-pyun","download_url":"https://codeload.github.com/hg-pyun/axios-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582905,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","javascript","logger","nodejs","pretty"],"created_at":"2024-10-03T10:44:36.949Z","updated_at":"2025-05-16T18:06:54.077Z","avatar_url":"https://github.com/hg-pyun.png","language":"JavaScript","funding_links":[],"categories":["Inspired by","JavaScript"],"sub_categories":["Custom filename"],"readme":"# axios-logger\n\n[![npm](https://img.shields.io/npm/v/axios-logger.svg)](https://www.npmjs.com/package/axios-logger)\n[![npm](https://img.shields.io/npm/dm/axios-logger.svg)](https://www.npmjs.com/package/axios-logger)\n[![GitHub license](https://img.shields.io/github/license/hg-pyun/axios-logger.svg)](https://github.com/hg-pyun/axios-logger/blob/master/LICENSE)\n[![CircleCI](https://circleci.com/gh/hg-pyun/axios-logger/tree/master.svg?style=svg)](https://circleci.com/gh/hg-pyun/axios-logger/tree/master)\n\n\u003e Beautify Axios Logging Messages.\n\n![logo](https://user-images.githubusercontent.com/10627668/71610488-dbdd5c80-2bd4-11ea-8a8a-15c0328bba0b.png)\n\nWhen you send a request in nodejs, you need to show the log to the console.\nThis library display the necessary information while communicating with the server.\n\nBasically This package is working as [Axios's interceptors](https://github.com/axios/axios#interceptors).\n\n![sample](https://user-images.githubusercontent.com/10627668/41816761-1700b662-77c8-11e8-80d4-7d223169364a.png)\n\n## Install\n\n```\n$ npm install axios-logger --save-dev\n```\n\n## How to use\n\nYou can use various loggers through the `axios`'s interceptor API.\n\n### Logging Request\n\n```javascript\nimport axios from 'axios';\nimport * as AxiosLogger from 'axios-logger';\n\nconst instance = axios.create();\ninstance.interceptors.request.use(AxiosLogger.requestLogger);\n```\n\nIf you want to use your own interceptor, you can compose(mixin) with `requestLogger`.\n\n```javascript\ninstance.interceptors.request.use((request) =\u003e {\n    // write down your request intercept.\n    return AxiosLogger.requestLogger(request);\n});\n```\n\n### Logging Response\n\n```javascript\nimport axios from 'axios';\nimport * as AxiosLogger from 'axios-logger';\n\nconst instance = axios.create();\ninstance.interceptors.response.use(AxiosLogger.responseLogger);\n```\n\nAlso if you want to use your own interceptor, you can compose(mixin) with `responseLogger`.\n\n```javascript\ninstance.interceptors.response.use((response) =\u003e {\n    // write down your response intercept.\n    return AxiosLogger.responseLogger(response);\n});\n```\n\n### Error\n\nYou can inject `errorLogger` right after `requestLogger` or `responseLogger`.\n\n```javascript\nimport axios from 'axios';\nimport * as AxiosLogger from 'axios-logger';\n\nconst instance = axios.create();\ninstance.interceptors.request.use(AxiosLogger.requestLogger, AxiosLogger.errorLogger);\ninstance.interceptors.response.use(AxiosLogger.responseLogger, AxiosLogger.errorLogger);\n```\n\nAlso if you want to use your own interceptor, you can compose(mixin) with `errorLogger`.\n\n```javascript\ninstance.interceptors.response.use(AxiosLogger.responseLogger, (err) =\u003e {\n    // write down your error intercept.\n    return AxiosLogger.errorLogger(err);\n});\n```\n\n## Configuration Settings\n\nYou can adjust several features as desired through configuration file.\nIf you want to set config globally, using `setGlobalConfig` method.\n\n```javascript\nsetGlobalConfig({\n    prefixText: 'your prefix',\n    dateFormat: 'HH:MM:ss',\n    status: false,\n    headers: true,\n    logger: someLogger.info.bind(this),\n});\n```\n\nOr it can also be passed on as a second argument and applied locally. In this case, any property explicitly defined will\noverride the global configuration.\n\n```javascript\ninstance.interceptors.request.use((request) =\u003e {\n    // write down your request intercept.\n    return AxiosLogger.requestLogger(request, {\n        prefixText: 'your prefix',\n        dateFormat: 'HH:MM:ss',\n        status: false,\n        headers: true,\n        logger: someLogger.error.bind(this),\n    });\n});\n```\n\n#### Enable config list\n\n| Property     | Type                                                                | Default       | Description                                                                                                                                    |\n| ------------ | ------------------------------------------------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |\n| `method`     | boolean                                                             | `true`        | Whether to include HTTP method or not.                                                                                                         |\n| `url`        | boolean                                                             | `true`        | Whether to include the URL or not.                                                                                                             |\n| `params`     | boolean                                                             | `false`       | Whether to include the URL params or not.                                                                                                      |\n| `data`       | boolean                                                             | `true`        | Whether to include request/response data or not.                                                                                               |\n| `status`     | boolean                                                             | `true`        | Whether to include response statuses or not.                                                                                                   |\n| `statusText` | boolean                                                             | `true`        | Whether to include response status text or not.                                                                                                |\n| `headers`    | boolean                                                             | `false`       | Whether to include HTTP headers or not.                                                                                                        |\n| `prefixText` | string \\| `false`                                                   | `'Axios'`     | `false` =\u003e no prefix, otherwise, customize the prefix wanted.                                                                                  |\n| `dateFormat` | [dateformat](https://github.com/felixge/node-dateformat) \\| `false` | `false`       | `false` =\u003e no timestamp, otherwise, customize its format                                                                                       |\n| `logger`     | function\u003cstring, any\u003e                                               | `console.log` | Allows users to customize the logger function to be used. e.g. Winston's `logger.info` could be leveraged, like this: `logger.info.bind(this)` |\n\n## CONTRIBUTE\n\nI always welcome Feedback and Pull Request :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhg-pyun%2Faxios-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhg-pyun%2Faxios-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhg-pyun%2Faxios-logger/lists"}