{"id":13413306,"url":"https://github.com/chzyer/logex","last_synced_at":"2025-12-15T00:31:51.873Z","repository":{"id":21702180,"uuid":"25023596","full_name":"chzyer/logex","owner":"chzyer","description":"An golang log lib, supports tracking and level, wrap by standard log lib","archived":false,"fork":false,"pushed_at":"2024-04-02T15:49:33.000Z","size":31,"stargazers_count":42,"open_issues_count":2,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-08T01:39:07.207Z","etag":null,"topics":[],"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/chzyer.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-10-10T06:38:39.000Z","updated_at":"2025-05-13T07:37:55.000Z","dependencies_parsed_at":"2024-06-18T13:57:01.268Z","dependency_job_id":"40a3976b-214a-48f5-9b62-477c1898b438","html_url":"https://github.com/chzyer/logex","commit_stats":null,"previous_names":["chzyer/gologex","go-logex/logex"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/chzyer/logex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chzyer%2Flogex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chzyer%2Flogex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chzyer%2Flogex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chzyer%2Flogex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chzyer","download_url":"https://codeload.github.com/chzyer/logex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chzyer%2Flogex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264922866,"owners_count":23683701,"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.309Z","updated_at":"2025-12-15T00:31:51.814Z","avatar_url":"https://github.com/chzyer.png","language":"Go","readme":"Logex\n=======\n[![Build Status](https://travis-ci.org/chzyer/logex.svg?branch=master)](https://travis-ci.org/chzyer/logex)\n[![GoDoc](https://godoc.org/github.com/chzyer/logex?status.svg)](https://godoc.org/github.com/chzyer/logex)\n\nAn golang log lib, supports tracing and level, wrap by standard log lib\n\nHow To Get\n=======\nshell\n```\ngo get github.com/chzyer/logex\n```\n\nsource code\n```{go}\nimport \"github.com/chzyer/logex\" // package name is logex\n\nfunc main() {\n  logex.Info(\"Hello!\")\n}\n```\n\nLevel\n=======\n\n```{go}\nimport \"github.com/chzyer/logex\"\n\nfunc main() {\n  logex.Println(\"\")\n  logex.Debug(\"debug staff.\") // Only show if has an \"DEBUG\" named env variable(whatever value).\n  logex.Info(\"info\")\n  logex.Warn(\"\")\n  logex.Fatal(\"\") // also trigger exec \"os.Exit(1)\"\n  logex.Error(err) // print error\n  logex.Struct(obj) // print objs follow such layout \"%T(%+v)\"\n  logex.Pretty(obj) // print objs as JSON-style, more readable and hide non-publish properties, just JSON\n}\n```\n\nExtendability\n======\n\nsource code\n```{go}\ntype MyStruct struct {\n  BiteMe bool\n}\n```\n\nmay change to\n\n```{go}\ntype MyStruct struct {\n  BiteMe bool\n  logex.Logger // just this\n}\n\nfunc main() {\n  ms := new(MyStruct)\n  ms.Info(\"woo!\")\n}\n```\n\nRuntime Tracing\n======\nAll log will attach theirs stack info. Stack Info will shown by an layout, `{packageName}.{FuncName}:{FileName}:{FileLine}`\n\n```{go}\npackage main\n\nimport \"github.com/chzyer/logex\"\n\nfunc test() {\n\tlogex.Pretty(\"hello\")\n}\n\nfunc main() {\n\ttest()\n}\n```\n\nresponse\n```\n2014/10/10 15:17:14 [main.test:testlog.go:6][PRETTY] \"hello\"\n```\n\nError Tracing\n======\nYou can trace an error if you want.\n\n```{go}\npackage main\n\nimport (\n\t\"github.com/chzyer/logex\"\n\t\"os\"\n)\n\nfunc openfile() (*os.File, error) {\n\tf, err := os.Open(\"xxx\")\n\tif err != nil {\n\t\terr = logex.Trace(err)\n\t}\n\treturn f, err\n}\n\nfunc test() error {\n\tf, err := openfile()\n\tif err != nil {\n\t\treturn logex.Trace(err)\n\t}\n\tf.Close()\n\treturn nil\n}\n\nfunc main() {\n\terr := test()\n\tif err != nil {\n\t\tlogex.Error(err)\n\t\treturn\n\t}\n\tlogex.Info(\"test success\")\n}\n```\n\n\nresponse\n```\n2014/10/10 15:22:29 [main.main:testlog.go:28][ERROR] [main.openfile:11;main.test:19] open xxx: no such file or directory\n```\n","funding_links":[],"categories":["Logging","Relational Databases","日志","Logging 日志库","\u003cspan id=\"日志-logging\"\u003e日志 Logging\u003c/span\u003e","日志记录","日誌"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","SQL 查询语句构建库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","检索及分析资料库","交流","高級控制台界面","高级控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchzyer%2Flogex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchzyer%2Flogex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchzyer%2Flogex/lists"}