{"id":45339356,"url":"https://github.com/omigo/log","last_synced_at":"2026-02-21T10:04:10.778Z","repository":{"id":57482222,"uuid":"49540045","full_name":"omigo/log","owner":"omigo","description":"定义一套 log 接口标准，类似 Java 的 slf4j，项目使用这套接口打印日志，可以随时切换不同的实现，打印出各种格式的日志。","archived":false,"fork":false,"pushed_at":"2022-05-24T08:50:49.000Z","size":296,"stargazers_count":6,"open_issues_count":0,"forks_count":11,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-13T18:35:15.364Z","etag":null,"topics":["golog","log4go","log4j","logger","logging"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"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/omigo.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":"2016-01-13T01:15:02.000Z","updated_at":"2024-12-26T09:55:29.000Z","dependencies_parsed_at":"2022-09-02T04:21:18.652Z","dependency_job_id":null,"html_url":"https://github.com/omigo/log","commit_stats":null,"previous_names":["arstd/log"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/omigo/log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omigo","download_url":"https://codeload.github.com/omigo/log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flog/sbom","scorecard":{"id":706235,"data":{"date":"2025-08-11","repo":{"name":"github.com/omigo/log","commit":"f283212f8ace8c5b4ee2cd5708ff4b501def9239"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/25 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'qlog'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T06:40:53.736Z","repository_id":57482222,"created_at":"2025-08-22T06:40:53.736Z","updated_at":"2025-08-22T06:40:53.736Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29679049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T09:33:50.764Z","status":"ssl_error","status_checked_at":"2026-02-21T09:33:19.949Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["golog","log4go","log4j","logger","logging"],"created_at":"2026-02-21T10:04:10.718Z","updated_at":"2026-02-21T10:04:10.770Z","avatar_url":"https://github.com/omigo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"log [![Build Status](https://travis-ci.org/omigo/log.svg?branch=master)](https://travis-ci.org/omigo/log) [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/omigo/log) [![license](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/omigo/log/master/LICENSE)\n================================================================================\n\n`log` 提供一\n个类型 `slf4j` 的标准接口，同时也提供了一个基本的实现，可以自定义日志格式，输出各种类型的日志，如\ncsv/json/xml，同时支持 Tag（TraceId/RequestId)。\n\n\nUsage\n-----\n\n安装：`go get -v -u github.com/omigo/log`\n\n使用：\n``` go\npackage main\n\nimport \"github.com/omigo/log\"\n\nfunc main() {\n    log.Debugf(\"this is a test message, %d\", 1111)\n\n\tformat := fmt.Sprintf(\"%s %s %s %s:%d %s\", \"2006-01-02 15:04:05.000000\", log.TagToken,\n\t\tlog.LevelToken, log.FileToken, log.LineToken, log.MessageToken)\n\tlog.SetFormat(format)\n\tlog.Tinfof(\"6ba7b814-9dad-11d1-80b4-00c04fd430c8\", \"this is a test message, %d\", 1111)\n\n\tformat = fmt.Sprintf(`{\"date\": \"%s\", \"time\": \"%s\", \"level\": \"%s\", \"file\": \"%s\", \"line\": %d, \"log\": \"%s\"}`,\n\t\t\"2006-01-02\", \"15:04:05.999\", log.LevelToken, log.FileToken, log.LineToken, log.MessageToken)\n\tlog.SetFormat(format)\n\tlog.Infof(\"this is a test message, %d\", 1111)\n\n\tformat = fmt.Sprintf(`\u003clog\u003e\u003cdate\u003e%s\u003c/date\u003e\u003ctime\u003e%s\u003c/time\u003e\u003clevel\u003e%s\u003c/level\u003e\u003cfile\u003e%s\u003c/file\u003e\u003cline\u003e%d\u003c/line\u003e\u003cmsg\u003e%s\u003c/msg\u003e\u003clog\u003e`,\n\t\t\"2006-01-02\", \"15:04:05.000\", log.LevelToken, log.FileToken, log.LineToken, log.MessageToken)\n\tlog.SetFormat(format)\n\tlog.Tinfof(\"6ba7b814-9dad-11d1-80b4-00c04fd430c8\", \"this is a test message, %d\", 1111)\n}\n```\n日志输出：\n```\n2016-01-16 20:28:34 debug main.go:10 this is a test message, 1111\n2016-01-16 20:28:34.280601 6ba7b814-9dad-11d1-80b4-00c04fd430c8 info main.go:15 this is a test message, 1111\n{\"date\": \"2016-01-16\", \"time\": \"20:28:34.28\", \"level\": \"info\", \"file\": \"main.go\", \"line\": 20, \"log\": \"this is a test message, 1111\"}\n\u003clog\u003e\u003cdate\u003e2016-01-16\u003c/date\u003e\u003ctime\u003e20:28:34.280\u003c/time\u003e\u003clevel\u003einfo\u003c/level\u003e\u003cfile\u003emain.go\u003c/file\u003e\u003cline\u003e25\u003c/line\u003e\u003cmsg\u003ethis is a test message, 1111\u003c/msg\u003e\u003clog\u003e\n```\n\n更多用法 [examples](main.go)\n着色示例 ![color.png](color.png)\n\nGo Doc and API\n--------------\n\n所有可调用的接口 API 和 文档都在 [log.go](log.go)\n\n\nlog/Printer/Standard\n--------------------\n\nGolang 不同于 Java，非面向对象语言（没有继承，只有组合，不能把组合实例赋给被组合的实例，即 Java\n说的 子对象 赋给 父对象），为了方便使用，很多函数都是包封装的，无需创建 struct ，就可以直接调用。\n（一般把裸露的方法称为函数，结构体和其他类型的方法才称为某某的方法）\n\nlog 包也一样，使用时，无需 new ，直接用。log 包有所有级别的函数可以调用，所有函数最终都调用了\nprint 函数。print 函数又调用了包内部变量的 std 的 Print 方法。这个 std 是一个 Printer 接\n口类型，定义了打印接口。用不同的实现改变 std 就可以打印出不同格式的日志，也可以输出到不同位置。\n（这个接口貌似还没有抽象好，再想想）\n\nPrinter 有个基本的实现 Standard，如果不改变，默认使用这个实现打印日志。\n\nStandard 实现了的 Printer 接口，把日志打印到 Stdout。\n\n\n性能测试\n-------\n\n环境：MacBookPro 15，4 核 8 线程 16G 内存\n\n实际测试结果（把日志重定向到文件）：\n该库平均每秒可输出 16w 行日志；\nGo 语言标准库平均每秒输出 36.5w 行日志。\n\n模板方式输出日志对性能有一定影响，其他 New Record 等也可能造成性能下降。但是实现上比标准库略微\n复杂，输出格式可以灵活配置，所以整体上可以接受，后期随着对 Go 语言的学习更深入再不断优化。\n\n\nTODO\n----\n\n* 测试是否支持各种格式的日期\n* 处理秒和毫秒，如1:1:02.9\n* 实现日志文件按一定规则自动滚动\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomigo%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomigo%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomigo%2Flog/lists"}