{"id":14989596,"url":"https://github.com/tilap/koa-request-log","last_synced_at":"2026-02-11T18:31:37.668Z","repository":{"id":54665590,"uuid":"57034535","full_name":"tilap/koa-request-log","owner":"tilap","description":"Koa request logger","archived":false,"fork":false,"pushed_at":"2018-10-19T00:27:45.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-27T05:27:14.458Z","etag":null,"topics":["koa-middleware","koa2","koajs"],"latest_commit_sha":null,"homepage":null,"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/tilap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-25T10:55:34.000Z","updated_at":"2018-08-29T07:30:24.000Z","dependencies_parsed_at":"2022-08-13T23:11:02.167Z","dependency_job_id":null,"html_url":"https://github.com/tilap/koa-request-log","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tilap/koa-request-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilap%2Fkoa-request-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilap%2Fkoa-request-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilap%2Fkoa-request-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilap%2Fkoa-request-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tilap","download_url":"https://codeload.github.com/tilap/koa-request-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilap%2Fkoa-request-log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29341216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T18:24:36.877Z","status":"ssl_error","status_checked_at":"2026-02-11T18:23:50.867Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["koa-middleware","koa2","koajs"],"created_at":"2024-09-24T14:18:37.636Z","updated_at":"2026-02-11T18:31:37.653Z","avatar_url":"https://github.com/tilap.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿Koa request logger [![NPM version][npm-image]][npm-url]\n============================\n\nSimple middleware **for Koa 2** to log in and out request, with diff time, and custom logger.\n\n## Install\n\n```\nnpm install --save koa-request-logger\n```\n\n## Usage\n\n```\nconst Koa = require('Koa');\nconst koaRequestLogger = require('koa-request-logger');\n\nconst app = new Koa();\napp.use(koaRequestLogger());\n\napp.listen(3000);\n```\n\n## Options\n\nYou can customize :\n\n- ```logger```, the logger object, by default ```console```\n- ```method```, the logger method, by default ```log```\n- ```format```, the output format function for IN and OUT request which takes params:\n  - ```ctx```: the koa context of the request\n  - ```id```: an unique ID to match in/out with easy\n  - ```isIn```: true if IN request, else false,\n  - ```timeDiff```: diff time for OUT requests (null for IN requests)\n\n### Example with winston as logger and custom log format\n\n```\nconst Koa = require('Koa');\nconst koaRequestLogger = require('koa-request-logger');\nconst winston = require('winston');\n\nconst logger = new (winston.Logger)({\n  transports: [\n    new (winston.transports.Console)(),\n    new (winston.transports.File)({ filename: 'somefile.log' })\n  ]\n});\n\nconst app = new Koa();\napp.use(koaRequestLogger({\n  logger,\n  method: 'info',\n  format: (ctx, id, isIn = true, timeDiff = null) =\u003e (isIn ?\n    `Incoming request #${id}: method ${ctx.request.method}, url ${ctx.request.url}` :\n    `Sending request results #${id}: method ${ctx.request.method}, url ${ctx.request.url}, status: ${ctx.status}, duration: ${timeDiff}ms`);\n}));\n\napp.listen(3000);\n```\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/koa-request-logger.svg?style=flat\n[npm-url]: https://npmjs.org/package/koa-request-logger\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilap%2Fkoa-request-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftilap%2Fkoa-request-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilap%2Fkoa-request-log/lists"}