{"id":18374541,"url":"https://github.com/jupiterone/node-bunyan-category","last_synced_at":"2025-08-19T05:09:28.427Z","repository":{"id":41975703,"uuid":"375056201","full_name":"JupiterOne/node-bunyan-category","owner":"JupiterOne","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-14T16:21:55.000Z","size":291,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-08-07T15:59:29.152Z","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/JupiterOne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-08T15:21:00.000Z","updated_at":"2021-10-01T20:31:44.000Z","dependencies_parsed_at":"2023-12-05T18:46:38.774Z","dependency_job_id":"6fe08d3d-25be-439b-a83a-9256f1c620d3","html_url":"https://github.com/JupiterOne/node-bunyan-category","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":"0.30000000000000004","last_synced_commit":"79e017a0fbdf77ba2a52b33140a914052cac261f"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/JupiterOne/node-bunyan-category","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fnode-bunyan-category","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fnode-bunyan-category/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fnode-bunyan-category/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fnode-bunyan-category/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JupiterOne","download_url":"https://codeload.github.com/JupiterOne/node-bunyan-category/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Fnode-bunyan-category/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271103202,"owners_count":24699646,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-06T00:15:01.385Z","updated_at":"2025-08-19T05:09:28.388Z","avatar_url":"https://github.com/JupiterOne.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bunyan-category\n\nThis project exports `CategoryLogger`. As you might expect, `CategoryLogger`\nderives from Bunyan's `Logger`. It is completely compatible with that interface,\nso feel free to swap it in without changing any of your code just yet.\n\n`CategoryLogger` accepts a category config and outputs logs (or doesn't) in\naccordance with its config. Here's a quick example:\n\n```\nconst logger = new CategoryLogger({\n  name: \"testing\",\n  config: {\n    Foo: \"warn\",\n    Bar: {\n      minLevel: \"warn\",\n      subConfig: {\n        Baz: \"info\",\n        Fizz: {\n          minLevel: \"info\"\n          conditional: {\n            minLevel: \"trace\",\n            foobar: true\n          }\n        }\n      },\n      conditional: {\n        minLevel: \"info\",\n        foobaz: true\n      }\n    },\n  },\n});\n\nlogger.trace({ category: \"Foo\" }, \"won't be logged\");\nlogger.info({ category: \"Foo\" }, \"won't be logged\");\nlogger.warn({ category: \"Foo\" }, \"will be logged\");\n\nlogger.trace({ category: \"Bar\" }, \"won't be logged\");\nlogger.info({ category: \"Bar\" }, \"won't be logged\");\nlogger.info({ category: \"Bar\", foobaz: true }, \"will be logged\");\nlogger.warn({ category: \"Bar\" }, \"will be logged\");\n\nlogger.trace({ category: \"Bar.Baz\" }, \"won't be logged\");\nlogger.trace({ category: \"Bar.Fizz\" }, \"won't be logged\");\nlogger.trace({ category: \"Bar.Fizz\", foobar: true }, \"will be logged\");\nlogger.info({ category: \"Bar.Baz\" }, \"will be logged\");\nlogger.warn({ category: \"Bar.Baz\" }, \"will be logged\");\n```\n\nIf a subconfig cannot be found for a category, the closest parent's minimum\nlevel will be used.\n\n```\nlogger.info({ category: \"Bar.Qux\" }, \"won't be logged\");\n```\n\nSince `CategoryLogger` is compatible with Bunyan, children work as you'd expect:\n\n```\nconst barLogger = logger.child({ category: 'Bar' });\n\nbar.info(\"won't be logged\");\nbar.warn(\"will be logged\");\n```\n\nPerformance can become an issue with high volume logs. To mitigate this,\nCategoryLogger adds another signature to Bunyan's log methods:\n\n```\nlogger.info(\"Foo\", () =\u003e [\n  { logProp: 123, thereCouldBeALotMoreOfThese: true },\n  \"This function will not be invoked\",\n]);\n```\n\nThe array returned from the constructor can be anything you would pass as\narguments to one of Bunyan's log methods.\n\n```\nlogger.warn(\n  \"Foo\",\n  () =\u003e [\"change da world; my final message\"]\n);\n\nlogger.warn(\n  \"Foo\",\n  () =\u003e [\"fancy %s\", formatting]\n);\n\n// etc. etc.\n```\n\nAs the example implies, the log properties constructor function will not be\ninvoked unless the CategoryLogger is actually going to output the log. This can\nsave a lot of memory and time for logs that you expect to be disabled most of\nthe time.\n\nAs a rule of thumb for best performance, if you expect a log to be disabled most\nof the time and only enabled for debugging, use the constructor signature. If a\nlog is always enabled, use the normal signature as it is slightly more\nperformant in that case.\n\nBut remember: no log is always the _most_ performant!\n\nNote: Category config conditionals will not work with high performance logs\nbecause we would need to evaluate the function in order to check if the\nconditional matches, which defeats the purpose of only calling the function when\nnecessary.\n\nCategoryLogger supports a `configProvider` option which you can use to control\nthe config of all loggers created for your application from a central location.\nThe object passed as the config provider must provide a `getConfig` method.\n\n```\nconst configProvider = {\n  config: {\n    Foo: \"warn\",\n  },\n  getConfig() {\n    return this.config;\n  },\n};\nconst logger = new CategoryLogger({\n  name: \"testing\",\n  configProvider,\n});\nconst child = logger.child({ category: \"Foo\" });\n\nlogger.info({ category: \"Foo\" }, \"won't be logged\");\nchild.info(\"won't be logged\");\nlogger.warn({ category: \"Foo\" }, \"will be logged\");\nchild.warn(\"will be logged\");\n\nconfigProvider.config = {\n  Foo: \"info\",\n};\n\nlogger.info({ category: \"Foo\" }, \"will be logged\");\nchild.info(\"will be logged\");\n```\n\nIf both `config` and `configProvider` are provided, `config` overrides\n`configProvider`.\n\nThis project provides a JSON schema for validating CategoryLogger configs which\nyou can use with services like AWS AppConfig to ensure that config deployments\nare valid.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Fnode-bunyan-category","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupiterone%2Fnode-bunyan-category","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Fnode-bunyan-category/lists"}