{"id":22213946,"url":"https://github.com/xmlking/logger","last_synced_at":"2025-07-27T12:31:54.766Z","repository":{"id":52548537,"uuid":"241694507","full_name":"xmlking/logger","owner":"xmlking","description":"meta logger for golang","archived":false,"fork":false,"pushed_at":"2022-06-18T17:40:25.000Z","size":85,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2024-06-21T15:20:02.661Z","etag":null,"topics":["golang","gorm","gorm-orm","logger","logrus","zap","zerolog"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/xmlking.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["xmlking"],"open_collective":"xmlking"}},"created_at":"2020-02-19T18:31:17.000Z","updated_at":"2020-03-22T00:33:46.000Z","dependencies_parsed_at":"2022-08-31T22:01:44.307Z","dependency_job_id":null,"html_url":"https://github.com/xmlking/logger","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmlking","download_url":"https://codeload.github.com/xmlking/logger/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227802821,"owners_count":17822113,"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":["golang","gorm","gorm-orm","logger","logrus","zap","zerolog"],"created_at":"2024-12-02T21:12:42.924Z","updated_at":"2024-12-02T21:12:43.616Z","avatar_url":"https://github.com/xmlking.png","language":"Go","readme":"# Logger\n\nLogger provides a simple facade over most popular logging systems for __GoLang__, allowing you to log in your application without vendor lock-in.\nThink SLF4J for GoLang.\n\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/xmlking/logger.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/xmlking/logger/alerts/)\n[![Language grade: Go](https://img.shields.io/lgtm/grade/go/g/xmlking/logger.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/xmlking/logger/context:go)\n\n## Usage\n\nImport dependencies. Use latest version.\n\n```go\nimport (\n\tgithub.com/xmlking/logger v0.1.4\n    // required: your choice of logger plugins\n\tgithub.com/xmlking/logger/zerolog v0.1.4\n    //optional: gormlog\n\tgithub.com/xmlking/logger/gormlog v0.1.4\n\n)\n```\n\n### Default logger\n\n```go\nfunc ExampleLog() {\n\tlogger.DefaultLogger = logger.NewLogger(logger.WithOutput(os.Stdout), logger.WithTimeFormat(\"ddd\"))\n\n\tlog.Info(\"test show info: \", \"msg \", true, 45.65)\n\tlog.Infof(\"test show infof: name: %s, age: %d\", \"sumo\", 99)\n\tlog.WithFields(map[string]interface{}{\n\t\t\"name\":  \"sumo\",\n\t\t\"age\":   99,\n\t\t\"alive\": true,\n\t}).Info(\"test show fields\")\n\tlog.WithError(errors.New(\"error message\")).Errorf(\"Testing: %s\", \"WithError\")\n\t// Output:\n\t//{\"level\":\"info\",\"message\":\"test show info: msg true 45.65\",\"time\":\"ddd\"}\n\t//{\"level\":\"info\",\"message\":\"test show infof: name: sumo, age: 99\",\"time\":\"ddd\"}\n\t//{\"age\":99,\"alive\":true,\"level\":\"info\",\"message\":\"test show fields\",\"name\":\"sumo\",\"time\":\"ddd\"}\n\t//{\"error\":\"error message\",\"level\":\"error\",\"message\":\"Testing: WithError\",\"time\":\"ddd\"}\n}\n```\n\n### Zerolog logger\n\n```go\nfunc ExampleWithFields() {\n\tlogger.DefaultLogger = zerolog.NewLogger(\n\t\tlogger.WithOutput(os.Stdout),\n\t\tlogger.WithTimeFormat(\"ddd\"),\n\t\tzerolog.WithProductionMode(),\n\t)\n\n\tlog.Info(\"testing: Info\")\n\tlog.Infof(\"testing: %s\", \"Infof\")\n\tlog.WithFields(map[string]interface{}{\n\t\t\"name\":  \"sumo\",\n\t\t\"age\":   99,\n\t\t\"alive\": true,\n\t}).Info(\"testing: with fields\")\n\t// Output:\n\t// {\"level\":\"info\",\"time\":\"ddd\",\"message\":\"testing: Info\"}\n\t// {\"level\":\"info\",\"time\":\"ddd\",\"message\":\"testing: Infof\"}\n\t// {\"level\":\"info\",\"age\":99,\"human\":true,\"sumo\":\"demo\",\"time\":\"ddd\",\"message\":\"testing: with fields\"}\n}\n```\n\n\n### For Contributors\n\n#### Prerequisites\n\n```bash\nbrew install hub\n# goup checks if there are any updates for imports in your module.\nGO111MODULE=on go get github.com/rvflash/goup\n# for static check/linter\nGO111MODULE=off go get github.com/golangci/golangci-lint/cmd/golangci-lint\n```\n\n#### Test\n\n```bash\nmake download\nmake test\nmake bench\n# Benchmark specific test\ncd zerolog\ngo test -run=^$ -bench=^BenchmarkInfoLog ./...\ngo test -run=^$ -bench=^BenchmarkInfoLog -benchtime 15s -count 2 -cpu 1,2,4 ./...\n# Results:\n# zerolog: 326443       3866 ns/op\n# wrapper: 324487       4280 ns/op\n```\n\n#### Release\n\n```bash\nmake download\ngit add .\n# Start release on develop branch\ngit flow release start v0.1.0\n# on release branch\ngit-chglog -c .github/chglog/config.yml -o CHANGELOG.md --next-tag v0.1.0\n# update `github.com/xmlking/logger` version in each `go.mod` file.\n# commit all changes.\n# finish release on release branch\ngit flow release finish\n# on master branch, (gpoat = git push origin --all \u0026\u0026 git push origin --tags)\ngpoat\n# add git tags for sub-modules\nmake release TAG=v0.1.0\n```\n\n### Reference\n- [How Zap Package is Optimized](https://medium.com/a-journey-with-go/go-how-zap-package-is-optimized-dbf72ef48f2d)\n- [zapdriver for Stackdriver logging](https://github.com/blendle/zapdriver)","funding_links":["https://github.com/sponsors/xmlking","https://opencollective.com/xmlking"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlking%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmlking%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlking%2Flogger/lists"}