{"id":19346787,"url":"https://github.com/arun0009/go-logger","last_synced_at":"2025-07-29T06:05:40.268Z","repository":{"id":73811718,"uuid":"318702426","full_name":"arun0009/go-logger","owner":"arun0009","description":"Logger interface with implementations (zap and logrus)","archived":false,"fork":false,"pushed_at":"2024-03-27T06:49:41.000Z","size":24,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-17T21:49:17.882Z","etag":null,"topics":["go","golang","logging-library","logrus","zap"],"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/arun0009.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":"2020-12-05T04:36:58.000Z","updated_at":"2025-01-03T07:52:46.000Z","dependencies_parsed_at":"2024-03-24T00:22:49.207Z","dependency_job_id":"580654fd-8bb2-46a2-bdef-c5b6f4be6ce2","html_url":"https://github.com/arun0009/go-logger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/arun0009/go-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arun0009%2Fgo-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arun0009%2Fgo-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arun0009%2Fgo-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arun0009%2Fgo-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arun0009","download_url":"https://codeload.github.com/arun0009/go-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arun0009%2Fgo-logger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267638850,"owners_count":24119764,"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-07-29T02:00:12.549Z","response_time":2574,"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":["go","golang","logging-library","logrus","zap"],"created_at":"2024-11-10T04:12:30.137Z","updated_at":"2025-07-29T06:05:40.231Z","avatar_url":"https://github.com/arun0009.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Logger interface with implementations (Zap and Logrus)\n\nYou can use `logger` as an interface (example below) and set actual implementation to `ReplaceGlobals`, this allows \nyou to change log library without changing your application code.\n\nAlso, when we create go libraries in general we shouldn't be logging but at times we do have to log, debug what the \nlibrary is doing or trace the log. \n\nWe cannot implement a library with one log library and expect applications to use the same log library. We use two \nof the popular log libraries [logrus](https://github.com/sirupsen/logrus) and [zap](https://github.com/uber-go/zap)\nand this `go-logger` library allows you to use either one by using an interface. \n\nYou can add your implementation if you want to add more log libraries (e.g. zerolog).\n\n## Installation\n\ngo get -u github.com/arun0009/go-logger\n\n## Quick Start\n\n[logrus](https://github.com/sirupsen/logrus) example\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/arun0009/go-logger/pkg/logger\"\n\t\"github.com/sirupsen/logrus\"\n)\n\nfunc main() {\n\tlogrusLog := logrus.New()\n\tlogrusLog.SetFormatter(\u0026logrus.JSONFormatter{})\n\tlogrusLog.SetOutput(os.Stdout)\n\tlogrusLog.SetLevel(logrus.DebugLevel)\n\tlog, _ := logger.NewLogrusLogger(logrusLog)\n\tlogger.ReplaceGlobals(log)\n        //anywhere in your code you can now use logger.L() as its globally set\n\tlogger.L().WithFields(logger.Fields{\n\t\t\"foo\": \"bar\",\n\t}).Info(\"direct\")\n}\n```\n\n[zap](https://github.com/uber-go/zap) example\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/arun0009/go-logger/pkg/logger\"\n\t\"go.uber.org/zap\"\n\t\"go.uber.org/zap/zapcore\"\n)\n\nfunc main() {\n\tconsoleEncoder := zapcore.NewJSONEncoder(zap.NewDevelopmentEncoderConfig())\n\tcore := zapcore.NewCore(consoleEncoder,\n\t\tzapcore.Lock(zapcore.AddSync(os.Stderr)),\n\t\tzapcore.DebugLevel)\n\tzapLogger := zap.New(core)\n\tlog, _ := logger.NewZapLogger(zapLogger)\n \tlogger.ReplaceGlobals(log)\n        //anywhere in your code you can now use logger.L() as its globally set\n\tlogger.L().WithFields(logger.Fields{\n\t\t\"foo\": \"bar\",\n\t}).Info(\"direct\")\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farun0009%2Fgo-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farun0009%2Fgo-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farun0009%2Fgo-logger/lists"}