{"id":17462856,"url":"https://github.com/mralias/go-logger","last_synced_at":"2025-03-28T06:41:04.523Z","repository":{"id":57531708,"uuid":"165176855","full_name":"MrAlias/go-logger","owner":"MrAlias","description":"Go package for severity based logging","archived":false,"fork":false,"pushed_at":"2019-01-12T02:42:00.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T07:26:14.064Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrAlias.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}},"created_at":"2019-01-11T04:03:10.000Z","updated_at":"2019-01-12T02:42:01.000Z","dependencies_parsed_at":"2022-09-07T04:51:18.287Z","dependency_job_id":null,"html_url":"https://github.com/MrAlias/go-logger","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/MrAlias%2Fgo-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrAlias%2Fgo-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrAlias%2Fgo-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrAlias%2Fgo-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrAlias","download_url":"https://codeload.github.com/MrAlias/go-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984561,"owners_count":20704794,"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":[],"created_at":"2024-10-18T09:10:06.573Z","updated_at":"2025-03-28T06:41:04.505Z","avatar_url":"https://github.com/MrAlias.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://api.travis-ci.com/MrAlias/go-logger.svg)](https://travis-ci.com/MrAlias/go-logger)\n\n# go-logger\n\nA simple and opinionated logging package for Go.\n\nThe core goal of this library is to provide severity based logging functionality in a concurrency safe manner.\n\nOutside of this core goal, this library tries to remaining as close to the standard [`log`](https://golang.org/pkg/log/) package as possible.\n\n## Usage\n\nThe most common way to use this library is by logging with the default logger.\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"sync\"\n\n\tkingpin \"gopkg.in/alecthomas/kingpin.v2\"\n\n\tlogger \"github.com/MrAlias/go-logger\"\n\tseverity \"github.com/MrAlias/go-logger/severity\"\n)\n\nvar logLevel = kingpin.Flag(\"log-level\", \"set minimum log level\").Default(\"INFO\").Enum(\"DEBUG\", \"INFO\", \"ERROR\")\n\nfunc main() {\n\tkingpin.Parse()\n\n\tswitch *logLevel {\n\tcase \"DEBUG\":\n\t\tlogger.SetSeverity(severity.Debug)\n\tcase \"INFO\":\n\t\tlogger.SetSeverity(severity.Info)\n\tcase \"ERROR\":\n\t\tlogger.SetSeverity(severity.Error)\n\tdefault:\n\t\tpanic(\"invalid log-level\")\n\t}\n\n\tvar wg sync.WaitGroup\n\tvar feeds = []string{\n\t\t\"https://xkcd.com/rss.xml\",\n\t\t\"https://blog.golang.org/feed.atom\",\n\t\t\"not a valid url\",\n\t}\n\tfor _, feed := range feeds {\n\t\twg.Add(1)\n\t\tgo func(f string) {\n\t\t\tdefer wg.Done()\n\t\t\tlogger.Debug(\"pulling feed: \", f)\n\t\t\tif _, err := http.Get(f); err != nil {\n\t\t\t\tlogger.Errorf(\"failed to pull %q: %v\", f, err)\n\t\t\t} else {\n\t\t\t\tlogger.Infof(\"pulled %q successfully\", f)\n\t\t\t}\n\t\t}(feed)\n\t}\n\twg.Wait()\n}\n```\n\nAn example of running the above code might look like this.\n\n```\n$ go run code-from-above.go --log-level=DEBUG\nDEBUG: pulling feed: not a valid url\nDEBUG: pulling feed: https://xkcd.com/rss.xml\nERROR: failed to pull \"not a valid url\": Get not%20a%20valid%20url: unsupported protocol scheme \"\"\nDEBUG: pulling feed: https://blog.golang.org/feed.atom\nINFO : pulled \"https://blog.golang.org/feed.atom\" successfully\nINFO : pulled \"https://xkcd.com/rss.xml\" successfully\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmralias%2Fgo-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmralias%2Fgo-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmralias%2Fgo-logger/lists"}