{"id":14969167,"url":"https://github.com/fastify/one-line-logger","last_synced_at":"2025-04-05T12:08:40.820Z","repository":{"id":45247975,"uuid":"513445573","full_name":"fastify/one-line-logger","owner":"fastify","description":"Helps you format fastify's log into a nice one line message","archived":false,"fork":false,"pushed_at":"2025-03-07T19:07:09.000Z","size":68,"stargazers_count":40,"open_issues_count":1,"forks_count":7,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-29T11:08:35.745Z","etag":null,"topics":["fastify-library"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@fastify/one-line-logger","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/fastify.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2022-07-13T08:45:00.000Z","updated_at":"2025-03-09T01:54:34.000Z","dependencies_parsed_at":"2023-02-06T07:10:25.575Z","dependency_job_id":"6788bfcb-7aa9-4ade-bedf-6aa7eef7e6b7","html_url":"https://github.com/fastify/one-line-logger","commit_stats":{"total_commits":47,"total_committers":11,"mean_commits":"4.2727272727272725","dds":0.6382978723404256,"last_synced_commit":"0f7d9a51f77e7ccc72e90e58a3139e2ca91953d8"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":"fastify/skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fone-line-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fone-line-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fone-line-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fone-line-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/one-line-logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247037115,"owners_count":20873098,"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":["fastify-library"],"created_at":"2024-09-24T13:41:15.927Z","updated_at":"2025-04-05T12:08:40.799Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"\u003ca id=\"@fastify/one-line-logger\"\u003e\u003c/a\u003e\n# @fastify/one-line-logger\n\n\n[![CI](https://github.com/fastify/one-line-logger/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/one-line-logger/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/one-line-logger.svg?style=flat)](https://www.npmjs.com/package/@fastify/one-line-logger)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\n`@fastify/one-line-logger` helps you format fastify's log into a nice one-line message:\n\n```\nYYYY-MM-dd HH:mm:ss.SSSTZ - \u003clevel\u003e - \u003cmethod\u003e \u003croute path\u003e - \u003cmessage\u003e\n```\n\nA standard incoming request log line like:\n\n```\n{\"level\": 30,\"time\": 1660151282194,\"pid\": 1557,\"hostname\": \"foo\",\"reqId\": \"req-1\",\"req\": {\"method\": \"GET\",\"url\": \"/path\",\"hostname\": \"localhost:8080\",\"remoteAddress\": \"127.0.0.1\"},\"msg\": \"incoming request\"}\n```\n\nWill format to:\n\n```\n2022-08-11 01:08:02.194+0100 - info - GET / - incoming request\n```\n\n\u003ca id=\"install\"\u003e\u003c/a\u003e\n## Install\n\n```\nnpm i @fastify/one-line-logger\n```\n\n\u003ca id=\"getting-started\"\u003e\u003c/a\u003e\n## Getting started\n\n```js\nconst server = fastify({\n  logger: {\n    transport: {\n      target: \"@fastify/one-line-logger\",\n    },\n  },\n});\n```\n\n## Colors\n\nColors are enabled by default when supported. To manually disable the colors you need to set the `transport.colorize` option to `false`. For more options check the `colorette` [docs](https://github.com/jorgebucaran/colorette?tab=readme-ov-file#environment).\n\n```js\nconst server = fastify({\n  logger: {\n    transport: {\n      target: \"@fastify/one-line-logger\",\n      colorize: false,\n    },\n  },\n});\n```\n\n\n## Custom levels\n\nCustom levels could be used by passing it into logger opts\n\n```js\nconst server = fastify({\n  logger: {\n    transport: {\n      target: \"@fastify/one-line-logger\",\n    },\n    customLevels: {\n      foo: 35,\n      bar: 45,\n    },\n  },\n});\n\nserver.get(\"/\", (request, reply) =\u003e {\n  request.log.info(\"time to foobar\");\n  request.log.foo(\"FOO!\");\n  request.log.bar(\"BAR!\");\n  reply.send({ foobar: true });\n});\n```\n\n## Custom level colors\n\nCustom level colors can be used by passing it into logger opts. They can also overwrite the default level's colors. Check all the supported colors [here](https://github.com/jorgebucaran/colorette?tab=readme-ov-file#supported-colors).\n\n```js\nconst server = fastify({\n  logger: {\n    transport: {\n      target: \"@fastify/one-line-logger\",\n      colors: {\n        35: \"bgYellow\",\n        45: \"magenta\",\n        60: \"bgRedBright\" // overwriting the `fatal` log color\n      }\n    },\n    customLevels: {\n      foo: 35,\n      bar: 45,\n    },\n  },\n});\n\nserver.get(\"/\", (request, reply) =\u003e {\n  request.log.fatal(\"An error occured\");\n  request.log.foo(\"FOO!\");\n  request.log.bar(\"BAR!\");\n  reply.send({ foobar: true });\n});\n```\n\n\u003ca id=\"license\"\u003e\u003c/a\u003e\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Fone-line-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Fone-line-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Fone-line-logger/lists"}