{"id":24302822,"url":"https://github.com/taigrr/log-mux","last_synced_at":"2026-04-17T23:02:31.905Z","repository":{"id":176682545,"uuid":"621030058","full_name":"taigrr/log-mux","owner":"taigrr","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-16T04:50:23.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T14:31:21.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taigrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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":"taigrr","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2023-03-29T21:15:24.000Z","updated_at":"2023-03-29T21:16:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"125b6a47-e87a-40e9-b469-6a97a120b5a7","html_url":"https://github.com/taigrr/log-mux","commit_stats":null,"previous_names":["taigrr/log-mux"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/taigrr/log-mux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Flog-mux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Flog-mux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Flog-mux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Flog-mux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taigrr","download_url":"https://codeload.github.com/taigrr/log-mux/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Flog-mux/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31949435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2025-01-17T00:19:30.759Z","updated_at":"2026-04-17T23:02:31.900Z","avatar_url":"https://github.com/taigrr.png","language":"Go","funding_links":["https://github.com/sponsors/taigrr"],"categories":[],"sub_categories":[],"readme":"# log-mux\n\nA Go logging multiplexer that fans out log calls to multiple backends simultaneously.\n\n## Installation\n\n```bash\ngo get github.com/taigrr/log-mux\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n\n    mlog \"github.com/taigrr/log-mux/log\"\n)\n\nfunc main() {\n    l := mlog.Default()\n\n    // Wrap the standard library logger (adds level methods like Info, Warn, etc.)\n    l.AddSubLogger(mlog.EnrichLogger(log.Default()))\n\n    // Add a second logger writing to stderr\n    errLog := log.New(os.Stderr, \"[ERR] \", log.LstdFlags)\n    l.AddSubLogger(mlog.EnrichLogger(errLog))\n\n    l.Info(\"this goes to all sub-loggers\")\n    l.Warn(\"so does this\")\n}\n```\n\n### Thread-Safe Sub-Logger Management\n\n```go\nl := mlog.Default()\n\n// Add and remove sub-loggers safely from any goroutine\nsl := mlog.EnrichLogger(log.Default())\nl.AddSubLogger(sl)\nl.RemoveSubLogger(sl)\nl.Len() // number of registered sub-loggers\n```\n\n### io.Writer Interface\n\nLogger implements `io.Writer`, so it can be used anywhere a writer is expected — for example, as the error log for an HTTP server:\n\n```go\nl := mlog.Default()\nl.AddSubLogger(mlog.EnrichLogger(log.Default()))\n\nserver := \u0026http.Server{\n    Addr:     \":8080\",\n    ErrorLog: log.New(l, \"[HTTP] \", log.LstdFlags),\n}\n```\n\n### Namespaced Loggers\n\n```go\n// Get or create a namespaced logger\nlogger, err := mlog.GetNSLogger(\"http\")\nif err == mlog.ErrNotExist {\n    // First access — logger was just created with no sub-loggers\n}\n\n// Configure it\nmlog.SetNSLogger(\"http\", mlog.Logger{\n    SubLoggers: []mlog.LevelLogger{mlog.EnrichLogger(log.Default())},\n})\n```\n\n### Custom Loggers\n\nAny type implementing `LevelLogger` can be added as a sub-logger. For loggers that only implement the standard `Print`/`Fatal`/`Panic` methods, use `EnrichLogger` to promote them to `LevelLogger`.\n\n## Log Levels\n\nAll standard levels are supported: `Trace`, `Debug`, `Info`, `Notice`, `Warn`, `Error`, `Panic`, `Fatal`, plus `Print` variants. Each level has plain, formatted (`f`), and newline (`ln`) variants.\n\n\u003e **Note:** `Panic` and `Fatal` calls may only reach the first sub-logger, since the standard library's implementations call `panic()`/`os.Exit()` immediately.\n\n## Thread Safety\n\nAll logging methods and sub-logger management (`AddSubLogger`, `RemoveSubLogger`, `Len`) are safe for concurrent use from multiple goroutines.\n\n## License\n\nSee [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaigrr%2Flog-mux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaigrr%2Flog-mux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaigrr%2Flog-mux/lists"}