{"id":21971370,"url":"https://github.com/go-log/log","last_synced_at":"2025-07-22T17:32:56.287Z","repository":{"id":57479555,"uuid":"90150034","full_name":"go-log/log","owner":"go-log","description":"A universal log interface","archived":false,"fork":false,"pushed_at":"2019-12-18T15:02:56.000Z","size":31,"stargazers_count":81,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T12:46:26.610Z","etag":null,"topics":["golang","logging"],"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/go-log.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":"2017-05-03T13:07:03.000Z","updated_at":"2024-11-08T04:08:16.000Z","dependencies_parsed_at":"2022-09-17T04:41:58.333Z","dependency_job_id":null,"html_url":"https://github.com/go-log/log","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-log%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-log%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-log%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-log%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-log","download_url":"https://codeload.github.com/go-log/log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227149547,"owners_count":17738250,"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","logging"],"created_at":"2024-11-29T14:50:20.421Z","updated_at":"2024-11-29T14:50:28.659Z","avatar_url":"https://github.com/go-log.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Log [![GoDoc](https://godoc.org/github.com/go-log/log?status.svg)](https://godoc.org/github.com/go-log/log)\n\nLog is a logging interface for Go. That's it. Pass around the interface.\n\n## Rationale\n\nUsers want to standardise logging. Sometimes libraries log. We leave the underlying logging implementation to the user \nwhile allowing libraries to log by simply expecting something that satisfies the `Logger` interface. This leaves\nthe user free to pre-configure structure, output, etc.\n\n## Interface\n\nThe interface is minimalistic on purpose:\n\n```go\ntype Logger interface {\n    Log(v ...interface{})\n    Logf(format string, v ...interface{})\n}\n```\n\nFor more motivation for this minimal interface, see [Dave Cheney's blog post][cheney].\n\n## Implementations\n\nLibraries will only need [the `Logger` interface](#interface), although they may choose to use [the `nest` package][nest] to create subloggers with additional context.\n\nCalling code will need to create a `Logger` interface, and there are a number of implementations and wrappers available to make that easy:\n\n* [capture][] is an implementation that saves logged lines in memory.\n    It is especially useful for unit tests that want to check for logged messages.\n* [fmt][] is an implementation wrapping [an `io.Writer`][io.Writer] like [`os.Stdout`][os.Stdout].\n    It uses [`fmt.Sprint`][fmt.Sprint] and [`Sprintf`][fmt.Sprintf] to generate the logged lines.\n* [info][] is an implementation wrapping `Info` and `Infof` calls.\n    It can be used to wrap implementations like [`glog.Verbose`][glog.Verbose] and [`logrus.Entry`][logrus.Entry.Info].\n* [print][] is an implementation wrapping `Print` and `Printf` calls.\n    It can be used to wrap implementations like [`glog.Verbose`][logrus.Entry.Print].\n* [log][] is an implementation wrapping [`log.Print`][log.Print] and [`log.Printf`][log.Printf].\n\nOutside of this repository, there are additional wrappers for:\n\n* [appengine/log][appengine], [here][appengine-wrapper].\n* [logrus][], [here][logrus-wrapper].\n    Although as mentioned above, you can also use the [info][] and [print][] wrappers for logrus.\n\nThe `Logger` interface is also simple enough to make writing your own implementation or wrapper very straightforward.\n\n## Example\n\nPre-configure a logger using [`WithFields`][logrus.WithFields] and pass it as an option to a library:\n\n```go\nimport (\n\t\"github.com/go-log/log/print\"\n\t\"github.com/lib/foo\"\n\t\"github.com/sirupsen/logrus\"\n)\n\nlogger := print.New(logrus.WithFields(logrus.Fields{\n\t\"library\": \"github.com/lib/foo\",\n}))\n\nf := foo.New(logger)\n```\n\n## Related projects\n\n[github.com/go-logr/logr][logr] is a similar interface approach to logging, although [the `logr.Logger` interface][logr.Logger] is more elaborate.\n\n[appengine]: https://cloud.google.com/appengine/docs/standard/go/logs/\n[appengine-wrapper]: https://github.com/go-log/appengine\n[capture]: https://godoc.org/github.com/go-log/log/capture\n[cheney]: https://dave.cheney.net/2015/11/05/lets-talk-about-logging\n[fmt]: https://godoc.org/github.com/go-log/log/fmt\n[fmt.Sprint]: https://golang.org/pkg/fmt/#Sprint\n[fmt.Sprintf]: https://golang.org/pkg/fmt/#Sprintf\n[glog.Verbose]: https://godoc.org/github.com/golang/glog#Verbose.Info\n[info]: https://godoc.org/github.com/go-log/log/info\n[io.Writer]: https://golang.org/pkg/io/#Writer\n[log]: https://godoc.org/github.com/go-log/log/log\n[log.Print]: https://golang.org/pkg/log/#Print\n[log.Printf]: https://golang.org/pkg/log/#Printf\n[logr]: https://github.com/go-logr/logr\n[logr.Logger]: https://godoc.org/github.com/go-logr/logr#Logger\n[logrus]: https://github.com/sirupsen/logrus\n[logrus-wrapper]: https://github.com/go-log/logrus\n[logrus.Entry.Info]: https://godoc.org/github.com/sirupsen/logrus#Entry.Info\n[logrus.Entry.Print]: https://godoc.org/github.com/sirupsen/logrus#Entry.Print\n[logrus.WithFields]: https://godoc.org/github.com/sirupsen/logrus#WithFields\n[nest]: https://godoc.org/github.com/go-log/log/nest\n[os.Stdout]: https://golang.org/pkg/os/#Stdout\n[print]: https://godoc.org/github.com/go-log/log/print\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-log%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-log%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-log%2Flog/lists"}