{"id":13413337,"url":"https://github.com/jfcg/yell","last_synced_at":"2025-03-14T19:31:54.082Z","repository":{"id":44961567,"uuid":"336828640","full_name":"jfcg/yell","owner":"jfcg","description":":ledger: Yet another minimalist logging library","archived":false,"fork":false,"pushed_at":"2022-03-01T22:01:45.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-31T20:52:14.743Z","etag":null,"topics":["go","golang","log","logger"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfcg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-07T16:07:27.000Z","updated_at":"2022-09-26T23:24:24.000Z","dependencies_parsed_at":"2022-07-13T11:10:32.664Z","dependency_job_id":null,"html_url":"https://github.com/jfcg/yell","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fyell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fyell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fyell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fyell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfcg","download_url":"https://codeload.github.com/jfcg/yell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635349,"owners_count":20322925,"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":["go","golang","log","logger"],"created_at":"2024-07-30T20:01:38.084Z","updated_at":"2025-03-14T19:31:53.796Z","avatar_url":"https://github.com/jfcg.png","language":"Go","funding_links":[],"categories":["Logging","日志记录","Relational Databases"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库"],"readme":"## yell [![go report card](https://goreportcard.com/badge/github.com/jfcg/yell)](https://goreportcard.com/report/github.com/jfcg/yell) [![go.dev ref](https://raw.githubusercontent.com/jfcg/.github/main/godev.svg)](https://pkg.go.dev/github.com/jfcg/yell#pkg-overview)\nyell is yet another minimalist logging library. It comes with:\n- four severity levels (info, warn, error, fatal)\n- simple API\n- [`io.Writer`](https://pkg.go.dev/io#Writer) \u0026 [`sync.Locker`](https://pkg.go.dev/sync#Locker) support\n- package-specific loggers\n- customizations (severity names, time format, local or UTC time)\n- easy, granular request location (file.go:line) logging\n- [semantic](https://semver.org) versioning\n\n### Example\nmypkg.go:\n```go\npackage mypkg\n\nimport (\n\t\"os\"\n\t\"github.com/jfcg/yell\"\n)\n\n// log to stdout with warn or higher severity (for example).\nvar Logger = yell.New(\": mypkg:\", os.Stdout, yell.Swarn)\n\n// Info tries to log message list with info severity\nfunc Info(msg ...interface{}) error {\n\treturn Logger.Log(yell.Sinfo, msg...)\n}\n\n// Warn tries to log message list with warn severity\nfunc Warn(msg ...interface{}) error {\n\treturn Logger.Log(yell.Swarn, msg...)\n}\n\n// Error tries to log message list with error severity\nfunc Error(msg ...interface{}) (err error) {\n\terr = Logger.Log(yell.Serror, msg...)\n\t// extra stuff for error severity\n\treturn\n}\n\n// Fatal tries to log message list with fatal severity and panics\nfunc Fatal(msg ...interface{}) (err error) {\n\terr = Logger.Log(yell.Sfatal, msg...)\n\tpm := Logger.Name() + yell.Sname[yell.Sfatal]\n\tif err != nil {\n\t\tpm += err.Error()\n\t}\n\t// probably panic or os.Exit(1) in a fatal situation\n\tpanic(pm)\n}\n```\nmyApp.go:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"mypkg\"\n\t\"github.com/jfcg/yell\"\n)\n\nfunc log() {\n\tdefer func() {\n\t\tfmt.Println(\"recovering:\", recover())\n\t}()\n\n\t// uses mypkg.Logger. yell records calling line in file.go:line format\n\tmypkg.Info(\"some info:\", 1, \"more\")\n\n\t// uses yell.Default Logger, minimum severity is warning by default\n\tyell.Warn(\"some warning:\", \"few details\")\n\n\t// record log() caller instead of this line\n\tmypkg.Error(yell.Caller(1), \"bad error\", 3.5, \"data\")\n\n\t// Fatal() logs \u0026 panicks\n\tyell.Fatal(\"fatal mistake\", 2, \"hard to recover\")\n}\n\nfunc main() {\n\t// minimum severity for mypkg.Logger is warning, so ignored\n\tmypkg.Info(\"some info:\", 3, \"more\")\n\n\t// set min severity level to info\n\tmypkg.Logger.SetLevel(yell.Sinfo)\n\tlog()\n\n\t// yell library uses local time by default, to get coordinated universal time\n\tyell.UTC = true\n\tlog()\n\n\t// change time format\n\tyell.TimeFormat = yell.TimeFormat[:19]\n\tlog()\n\n\t// customized severity names (increasing severity)\n\tyell.Sname = [...]string{\"信息:\", \"警告:\", \"错误:\", \"致命的:\"}\n\tyell.UTC = false\n\tlog()\n\n\t// disable logging for yell.Default\n\tyell.Default.SetLevel(yell.Snolog)\n\tlog()\n}\n```\noutput:\n```\n2021-03-28 21:48:53.591948: mypkg:info: myApp.go:15: some info: 1 more\n2021-03-28 21:48:53.592051: myApp:warn: myApp.go:18: some warning: few details\n2021-03-28 21:48:53.592063: mypkg:error: myApp.go:33: bad error 3.5 data\n2021-03-28 21:48:53.592082: myApp:fatal: myApp.go:24: fatal mistake 2 hard to recover\nrecovering: myApp:fatal:\n2021-03-28 18:48:53.592100: mypkg:info: myApp.go:15: some info: 1 more\n2021-03-28 18:48:53.592110: myApp:warn: myApp.go:18: some warning: few details\n2021-03-28 18:48:53.592118: mypkg:error: myApp.go:37: bad error 3.5 data\n2021-03-28 18:48:53.592126: myApp:fatal: myApp.go:24: fatal mistake 2 hard to recover\nrecovering: myApp:fatal:\n2021-03-28 18:48:53: mypkg:info: myApp.go:15: some info: 1 more\n2021-03-28 18:48:53: myApp:warn: myApp.go:18: some warning: few details\n2021-03-28 18:48:53: mypkg:error: myApp.go:41: bad error 3.5 data\n2021-03-28 18:48:53: myApp:fatal: myApp.go:24: fatal mistake 2 hard to recover\nrecovering: myApp:fatal:\n2021-03-28 21:48:53: mypkg:信息: myApp.go:15: some info: 1 more\n2021-03-28 21:48:53: myApp:警告: myApp.go:18: some warning: few details\n2021-03-28 21:48:53: mypkg:错误: myApp.go:46: bad error 3.5 data\n2021-03-28 21:48:53: myApp:致命的: myApp.go:24: fatal mistake 2 hard to recover\nrecovering: myApp:致命的:\n2021-03-28 21:48:53: mypkg:信息: myApp.go:15: some info: 1 more\n2021-03-28 21:48:53: mypkg:错误: myApp.go:50: bad error 3.5 data\nrecovering: myApp:致命的:\n```\n\n### Support\nIf you use yell and like it, please support via:\n- BTC:`bc1qr8m7n0w3xes6ckmau02s47a23e84umujej822e`\n- ETH:`0x3a844321042D8f7c5BB2f7AB17e20273CA6277f6`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfcg%2Fyell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfcg%2Fyell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfcg%2Fyell/lists"}