{"id":20229589,"url":"https://github.com/janeczku/stdemuxerhook","last_synced_at":"2025-04-10T17:50:47.760Z","repository":{"id":144200896,"uuid":"88107072","full_name":"janeczku/stdemuxerhook","owner":"janeczku","description":":twisted_rightwards_arrows: A hook for logrus logger that demuxes logs to stderr and stdout based on severity","archived":false,"fork":false,"pushed_at":"2019-03-01T06:17:12.000Z","size":1,"stargazers_count":5,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T15:41:28.529Z","etag":null,"topics":["logger","logging","logrus","stderr","stdout"],"latest_commit_sha":null,"homepage":"","language":"Go","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/janeczku.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}},"created_at":"2017-04-13T00:03:11.000Z","updated_at":"2024-09-27T11:36:51.000Z","dependencies_parsed_at":"2023-06-18T10:33:13.398Z","dependency_job_id":null,"html_url":"https://github.com/janeczku/stdemuxerhook","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/janeczku%2Fstdemuxerhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janeczku%2Fstdemuxerhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janeczku%2Fstdemuxerhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janeczku%2Fstdemuxerhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janeczku","download_url":"https://codeload.github.com/janeczku/stdemuxerhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262424,"owners_count":21074307,"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":["logger","logging","logrus","stderr","stdout"],"created_at":"2024-11-14T07:36:15.564Z","updated_at":"2025-04-10T17:50:47.754Z","avatar_url":"https://github.com/janeczku.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A stdout/stderr demuxer hook for Logrus\n\n[Logrus](https://github.com/Sirupsen/logrus) loggers always output all log levels to a single common output, e.g. `stderr`. \nThis logrus hook makes it so that logs with a severity below `Error` are written to `stdout` while all the important stuff goes to `stderr`.\n\nYou can also use the hook to demux logs to custom IO writers based on severity. Just override the default outputs using the hook's `SetOutput(infoLevel, errorLevel io.Writer)` method.\n\n## Example\n\nGiven you have an application that uses a the logrus standard logger similar to this:\n\n```go\nimport (\n    log \"github.com/Sirupsen/logrus\"\n)\n\nfunc main() {\n\n    log.SetLevel(log.InfoLevel)\n\n    log.Info(\"A group of penguins emerges from the ocean\")\n\n    (...)\n\n```\n\nThe only change required is adding in the hook. Make sure to configure the parent logger before initializing the hook as the latter will inherit it's configuration.\n\n```go\nimport (\n    log \"github.com/Sirupsen/logrus\"\n    \"github.com/janeczku/stdemuxerhook\"\n)\n\nfunc main() {\n\n    log.SetLevel(log.InfoLevel)\n    log.AddHook(stdemuxerhook.New(log.StandardLogger()))\n\n    log.Info(\"A group of penguins emerges from the ocean\") // -\u003e logged to stdout\n    log.Panic(\"A group of polar bears emerges from the ocean\") // -\u003e logged to stderr\n\n    (...)\n\n}\n```\n\n## Benchmarks\n\n```BASH\nBenchmarkLoggerWithoutHook        300000          4348 ns/op\nBenchmarkLoggerWithHook           200000          5436 ns/op\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneczku%2Fstdemuxerhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaneczku%2Fstdemuxerhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneczku%2Fstdemuxerhook/lists"}