{"id":19298628,"url":"https://github.com/ibbd-dev/go-async-log","last_synced_at":"2026-03-01T03:01:54.223Z","repository":{"id":57482589,"uuid":"72592844","full_name":"ibbd-dev/go-async-log","owner":"ibbd-dev","description":"Golang异步日志库，支持异步批量写入，按天或者小时自动切割，错误等级，多文件等","archived":false,"fork":false,"pushed_at":"2017-12-16T13:04:39.000Z","size":14,"stargazers_count":35,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-22T09:45:17.831Z","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/ibbd-dev.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-11-02T01:39:32.000Z","updated_at":"2024-12-18T13:41:45.000Z","dependencies_parsed_at":"2022-09-02T06:20:47.312Z","dependency_job_id":null,"html_url":"https://github.com/ibbd-dev/go-async-log","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ibbd-dev/go-async-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibbd-dev%2Fgo-async-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibbd-dev%2Fgo-async-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibbd-dev%2Fgo-async-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibbd-dev%2Fgo-async-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibbd-dev","download_url":"https://codeload.github.com/ibbd-dev/go-async-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibbd-dev%2Fgo-async-log/sbom","scorecard":{"id":479043,"data":{"date":"2025-08-11","repo":{"name":"github.com/ibbd-dev/go-async-log","commit":"5ed575527eed64d218351d793e05e448d500f868"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"Code-Review","score":0,"reason":"Found 1/22 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":"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":"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":"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":"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":"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":"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":"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"}},{"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'"],"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 2 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"}}]},"last_synced_at":"2025-08-19T16:05:53.147Z","repository_id":57482589,"created_at":"2025-08-19T16:05:53.148Z","updated_at":"2025-08-19T16:05:53.148Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29959284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-09T23:08:34.534Z","updated_at":"2026-03-01T03:01:54.203Z","avatar_url":"https://github.com/ibbd-dev.png","language":"Go","readme":"# 异步日志库\n\n## Install\n\n```sh\ngo get -u github.com/ibbd-dev/go-async-log\n```\n\n## 实现的功能及说明\n\n- 多个日志文件写入：例如错误信息一个文件，测试信息一个文件等\n- 日志自动切割：前期支持按小时或者天切割\n- 支持批量写入：最小单位为100毫秒，不同的文件可以设置不同的写入频率（周期性写入，程序挂掉的时候最多可能会丢一个周期的数据，重要数据不能采用该方式\n- 同时支持实时写入文件，使用文件系统缓存（只要系统不挂，就不会有问题）\n- 错误等级实现\n- 可以写入json数据\n- 时间格式采用`RFC3339`，格式如`2006-01-02T15:04:05Z07:00`\n- 支持按概率写log\n\n## 配置项\n\n- 文件名\n- 日志记录的等级\n- 自动切割周期：默认按小时\n- 批量写入周期：默认每秒写入一次\n- 异常等级：\n- 是否需要Flags：默认需要\n\n## Example\n\n普通写入日志文件\n\n```go\nlf := asyncLog.NewLogFile(\"/tmp/test.log\")\n\n// 设置按天切割文件，如果默认则是按小时\nlf.SetRotate(asyncLog.RotateDate)\n\nlf.SetProbability(0.5) // 设置写log的概率，默认全部都写入\n\n_ = lf.Write(\"lf: hello world\")\n\n// 注意：因为是每秒写入一次，所以这里需要暂停一下\ntime.Sleep(time.Second * 2)\n\n```\n\n写入错误等级文件\n\n```go\ninfoFile := asyncLog.NewLevelLog(\"/tmp/test-info.log\", asyncLog.LevelInfo)  // 只有Info级别或者以上级别的日志才会被记录\ninfoFile.SetProbability(0.5) // 设置写log的概率，默认全部都写入\ninfoFile.Debug(\"hello world\") // 该日志不会写入文件\ninfoFile.Info(\"hello world\")\ninfoFile.Error(\"hello world\")\n\n// 需要改变日志写入等级时，例如测试阶段\ninfoFile.SetLevel(asyncLog.LevelDebug)\n\ntime.Sleep(time.Second * 2)\n```\n\n## 性能数据\n\n不缓存内容的时候，如果不对文件句柄进行缓存重用，性能是比较低的，如下：（这是旧版本）\n\n```sh\n# go test -bench=\".*\"\nBenchmarkWrite-4          \t 3000000\t       444 ns/op\nBenchmarkWriteNoCache-4   \t  300000\t      4400 ns/op\n```\n\n对句柄进行缓存重用之后，性能如下：\n\n```sh\nBenchmarkWrite-4          \t 3000000\t       570 ns/op\nBenchmarkWriteNoCache-4   \t 1000000\t      2304 ns/op\n```\n\n结论：对句柄进行缓存，是能大大提升效率的。\n\n-------\n\n性能比`github.com/ibbd-dev/go-tools/logfile`至少提升一个数量级\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibbd-dev%2Fgo-async-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibbd-dev%2Fgo-async-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibbd-dev%2Fgo-async-log/lists"}