{"id":13413301,"url":"https://github.com/heartwilltell/log","last_synced_at":"2026-01-17T17:23:17.066Z","repository":{"id":43719928,"uuid":"487624499","full_name":"heartwilltell/log","owner":"heartwilltell","description":"Simple leveled logging wrapper around standard log package","archived":false,"fork":false,"pushed_at":"2022-12-06T14:24:16.000Z","size":291,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:52:12.146Z","etag":null,"topics":["go","golang","lib","library","log","logger","logging","logging-library","zero-dependency"],"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/heartwilltell.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":".github/CODEOWNERS.md","security":null,"support":null}},"created_at":"2022-05-01T19:29:10.000Z","updated_at":"2024-06-27T21:34:19.000Z","dependencies_parsed_at":"2023-01-24T02:01:09.973Z","dependency_job_id":null,"html_url":"https://github.com/heartwilltell/log","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/heartwilltell/log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heartwilltell","download_url":"https://codeload.github.com/heartwilltell/log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Flog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28512748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","lib","library","log","logger","logging","logging-library","zero-dependency"],"created_at":"2024-07-30T20:01:37.186Z","updated_at":"2026-01-17T17:23:17.025Z","avatar_url":"https://github.com/heartwilltell.png","language":"Go","readme":"# `log` - Simple leveled logging based on standard log package\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://imagedelivery.net/r-FGMwXlTVvJHWFyznDr1Q/b6462eaf-74a1-4225-8548-45c4c8ea0100/public\" width=\"800\" title=\"hover text\" alt=\"logo\"\u003e\n\u003c/p\u003e\n\n## Documentation\n[![](https://goreportcard.com/badge/github.com/heartwilltell/log)](https://goreportcard.com/report/github.com/heartwilltell/log)\n[![](https://pkg.go.dev/badge/github.com/heartwilltell/log?utm_source=godoc)](https://pkg.go.dev/github.com/heartwilltell/log)\n[![Build](https://github.com/heartwilltell/log/actions/workflows/pr.yml/badge.svg?branch=master\u0026event=push)](https://github.com/heartwilltell/log/actions/workflows/pr.yml)\n[![codecov](https://codecov.io/gh/heartwilltell/log/branch/master/graph/badge.svg?token=JFY9EQ4F2A)](https://codecov.io/gh/heartwilltell/log)\n\n## Benefits\n\n- 😻 Leveled logging\n- 😚 Simple API\n- 🤝 `fmt` friendly\n- 👌 Zero dependencies\n- 😮‍💨 No global logger\n- 👏 No structured logging bullshit\n\n\n## Installation\n```bash\ngo get github.com/heartwilltell/log\n```\n\n## Leveled logging\n\nThe `StdLog` implements a simple interface:\n```go\n// Logger formats the message according to standard format specifiers from the fmt package\n// and writes the message to writer specified by the concrete interface implementation.\ntype Logger interface {\n\t// Error formats and writes the error level message.\n\tError(format string, v ...any)\n\t// Warning formats and writes the warning level message.\n\tWarning(format string, v ...any)\n\t// Info formats and writes the information level message.\n\tInfo(format string, v ...any)\n\t// Debug formats and writes the debug level message.\n\tDebug(format string, v ...any)\n}\n```\n\n## Usage\n\n👇 The usage is pretty simple. Just create a logger instance and call any of leveled methods.\n```go\nlogger := log.New()\nlogger.Info(\"Listen on port: %d\", 8080)\n```\n###\n\n👇 Sets the logging level to `debug` level.\n```go\nlogger := log.New(log.WithLevel(log.DBG))\n```\n###\n\n👇 Parses string to level and creates logger with `warning` level.\n```go\nlevel, levelErr := log.ParseLevel(\"warning\")\nif levelErr != nil {\n\t// handle error here\n}\n\nlogger := log.New(log.WithLevel(level))\n```\n###\n\n👇 Creates logger with different `io.Writer`.\n```go\nvar w bytes.Buffer \n\nlogger := log.New(log.WithWriter(w))\n```\n###\n\n👇 Disables the colorful output.\n```go\nlogger := log.New(log.WithNoColor())\n```\n###\n\n👇 Sets the UTC time format.\n```go\nlogger := log.New(log.WithUTC())\n```\n###\n\n👇 Enables printing the code line number.\n```go\n// Short format:\n// INF: 2022/07/08 11:22:30 server.go:111: message\nlogger := log.New(log.WithLineNum(log.ShortFmt))\n```\nOR\n```go\n// Long format:\n// INF: 2022/07/08 11:22:30 /Users/heartwilltell/Go/app/server.go:111: message\nlogger := log.New(log.WithLineNum(log.LongFmt))\n```\n###\n\n👇 Sets the level mark at the end of log prefix.\n```go\nlogger := log.New(log.WithLevelAtPrefixEnd())\n```\nWill produce this 👇\n```\n// 2022/07/08 11:22:30 INF: message\n```\nInstead of this 👇\n```\n// INF: 2022/07/08 11:22:30: message\n```\n\n###\n\n👇 Creates nop logger which implements `log.Logger` interface.\n```go\nlogger := log.NewNopLog()\n```\n💡 _Useful for tests or places where logger should be disabled by default_\n\n## License\n[MIT License](LICENSE).","funding_links":[],"categories":["日志记录","Logging"],"sub_categories":["检索及分析资料库","Search and Analytic Databases"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheartwilltell%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheartwilltell%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheartwilltell%2Flog/lists"}