{"id":13413304,"url":"https://github.com/inconshreveable/log15","last_synced_at":"2025-04-10T20:12:23.987Z","repository":{"id":17194285,"uuid":"19961931","full_name":"inconshreveable/log15","owner":"inconshreveable","description":"Structured, composable logging for Go","archived":false,"fork":false,"pushed_at":"2023-02-21T18:38:46.000Z","size":212,"stargazers_count":1103,"open_issues_count":45,"forks_count":145,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-10-29T15:03:30.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/inconshreveable/log15","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inconshreveable.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":"2014-05-20T00:11:52.000Z","updated_at":"2024-09-30T02:41:37.000Z","dependencies_parsed_at":"2024-06-18T11:10:01.826Z","dependency_job_id":"cb694280-eb9a-436a-bf6b-be647ba42738","html_url":"https://github.com/inconshreveable/log15","commit_stats":{"total_commits":118,"total_committers":31,"mean_commits":3.806451612903226,"dds":0.6101694915254237,"last_synced_commit":"5555550548196f43bf6dda2648158a72c416f9e7"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Flog15","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Flog15/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Flog15/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inconshreveable%2Flog15/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inconshreveable","download_url":"https://codeload.github.com/inconshreveable/log15/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288361,"owners_count":21078903,"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-07-30T20:01:37.259Z","updated_at":"2025-04-10T20:12:23.964Z","avatar_url":"https://github.com/inconshreveable.png","language":"Go","funding_links":[],"categories":["日志记录","Logging","Go (134)","Go","Logging 日志库","\u003cspan id=\"日志-logging\"\u003e日志 Logging\u003c/span\u003e","Relational Databases","日志","日誌"],"sub_categories":["检索及分析资料库","Advanced Console UIs","Search and Analytic Databases","SQL 查询语句构建库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流","高級控制台界面","高级控制台界面"],"readme":"![obligatory xkcd](http://imgs.xkcd.com/comics/standards.png)\n\n# log15 [![godoc reference](https://godoc.org/github.com/inconshreveable/log15?status.png)](https://godoc.org/github.com/inconshreveable/log15) [![Build Status](https://travis-ci.org/inconshreveable/log15.svg?branch=master)](https://travis-ci.org/inconshreveable/log15)\n\nPackage log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](http://golang.org/pkg/io/) and [`net/http`](http://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](http://golang.org/pkg/log/) package.\n\n## Features\n- A simple, easy-to-understand API\n- Promotes structured logging by encouraging use of key/value pairs\n- Child loggers which inherit and add their own private context\n- Lazy evaluation of expensive operations\n- Simple Handler interface allowing for construction of flexible, custom logging configurations with a tiny API.\n- Color terminal support\n- Built-in support for logging to files, streams, syslog, and the network\n- Support for forking records to multiple handlers, buffering records for output, failing over from failed handler writes, + more\n\n## Versioning\nThe API of the master branch of log15 should always be considered unstable. If you want to rely on a stable API,\nyou must vendor the library.\n\n## Importing\n\n```go\nimport log \"github.com/inconshreveable/log15\"\n```\n\n## Examples\n\n```go\n// all loggers can have key/value context\nsrvlog := log.New(\"module\", \"app/server\")\n\n// all log messages can have key/value context\nsrvlog.Warn(\"abnormal conn rate\", \"rate\", curRate, \"low\", lowRate, \"high\", highRate)\n\n// child loggers with inherited context\nconnlog := srvlog.New(\"raddr\", c.RemoteAddr())\nconnlog.Info(\"connection open\")\n\n// lazy evaluation\nconnlog.Debug(\"ping remote\", \"latency\", log.Lazy{pingRemote})\n\n// flexible configuration\nsrvlog.SetHandler(log.MultiHandler(\n    log.StreamHandler(os.Stderr, log.LogfmtFormat()),\n    log.LvlFilterHandler(\n        log.LvlError,\n        log.Must.FileHandler(\"errors.json\", log.JsonFormat()))))\n```\n\nWill result in output that looks like this:\n\n```\nWARN[06-17|21:58:10] abnormal conn rate                       module=app/server rate=0.500 low=0.100 high=0.800\nINFO[06-17|21:58:10] connection open                          module=app/server raddr=10.0.0.1\n```\n\n## Breaking API Changes\nThe following commits broke API stability. This reference is intended to help you understand the consequences of updating to a newer version\nof log15.\n\n- 57a084d014d4150152b19e4e531399a7145d1540 - Added a `Get()` method to the `Logger` interface to retrieve the current handler\n- 93404652ee366648fa622b64d1e2b67d75a3094a - `Record` field `Call` changed to `stack.Call` with switch to `github.com/go-stack/stack`\n- a5e7613673c73281f58e15a87d2cf0cf111e8152 - Restored `syslog.Priority` argument to the `SyslogXxx` handler constructors\n\n## FAQ\n\n### The varargs style is brittle and error prone! Can I have type safety please?\nYes. Use `log.Ctx`:\n\n```go\nsrvlog := log.New(log.Ctx{\"module\": \"app/server\"})\nsrvlog.Warn(\"abnormal conn rate\", log.Ctx{\"rate\": curRate, \"low\": lowRate, \"high\": highRate})\n```\n\n### Regenerating the CONTRIBUTORS file\n\n```\ngo get -u github.com/kevinburke/write_mailmap\nwrite_mailmap \u003e CONTRIBUTORS\n```\n\n## License\nApache\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finconshreveable%2Flog15","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finconshreveable%2Flog15","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finconshreveable%2Flog15/lists"}