{"id":16815629,"url":"https://github.com/ericzon/logger-wrapper-with-cls","last_synced_at":"2025-03-17T12:28:48.223Z","repository":{"id":146720745,"uuid":"168141465","full_name":"ericzon/logger-wrapper-with-cls","owner":"ericzon","description":"Example of cls showing how to forward request id through application flow.","archived":false,"fork":false,"pushed_at":"2020-03-02T17:57:38.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T22:17:48.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericzon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-01-29T11:11:05.000Z","updated_at":"2020-03-02T17:57:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"40a9a348-3bac-45dc-8363-ee319c911633","html_url":"https://github.com/ericzon/logger-wrapper-with-cls","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericzon%2Flogger-wrapper-with-cls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericzon%2Flogger-wrapper-with-cls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericzon%2Flogger-wrapper-with-cls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericzon%2Flogger-wrapper-with-cls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericzon","download_url":"https://codeload.github.com/ericzon/logger-wrapper-with-cls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244033104,"owners_count":20386875,"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":[],"created_at":"2024-10-13T10:35:01.797Z","updated_at":"2025-03-17T12:28:48.203Z","avatar_url":"https://github.com/ericzon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"CLS-EXAMPLE\n===========\n\nSimple example of [CLS](https://github.com/jeff-lewis/cls-hooked) (Continuation-Local Storage) showing how to forward request id through application flow.\n\nLogger used: [Pino.js](https://github.com/pinojs/pino)\n\nWorking with node versions \u003e= 10.15.x (lts)\n\n**Environment**\n```\nPORT: \u003c3000 by default\u003e\n```\n\n**Install**\n\n```\nnpm i\n```\n\n**Start**\n\n```\nnpm start\n```\n\nThen go to http://localhost:{PORT}/ping and check the logs:\n\n```\n[1548759313580] INFO: Server listening in 3000\n[1548759322510] INFO: saying hello...\n    requestId: \"cjrhnb9fw000074yfhq6bri6z\"\n[1548759322513] INFO: Ping says: Hello Ping\n    requestId: \"cjrhnb9fw000074yfhq6bri6z\"\n```\nIf we repeat the request, we can check how new a requestId is attached during all the application flow.\n```\n[1548759324016] INFO: saying hello...\n    requestId: \"cjrhnbals000174yf7z9hg4h8\"\n[1548759324016] INFO: Ping says: Hello Ping\n    requestId: \"cjrhnbals000174yf7z9hg4h8\"\n\n```\n\nYou can customize ids sending a value in 'X-Request-Id' header.\n\n\n**Credits**\n\nExample adapted from these posts:\n\n- https://itnext.io/give-your-logs-more-context-7b43ea6b4ae6\n- https://itnext.io/give-your-logs-more-context-part-2-c2c952724e04\n- https://github.com/Jeff-Lewis/cls-hooked/issues/29\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericzon%2Flogger-wrapper-with-cls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericzon%2Flogger-wrapper-with-cls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericzon%2Flogger-wrapper-with-cls/lists"}