{"id":38247335,"url":"https://github.com/zbh255/bilog","last_synced_at":"2026-01-17T01:24:39.058Z","repository":{"id":41086212,"uuid":"449991713","full_name":"zbh255/bilog","owner":"zbh255","description":"bilog被设计为可以在需要性能，简单日志的场景下可以替换std log，它关注性能与轻量的实现。","archived":false,"fork":false,"pushed_at":"2023-01-15T17:23:08.000Z","size":116,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-07-27T22:49:23.413Z","etag":null,"topics":["go","golang","high-performance-logger","log-library","logger"],"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/zbh255.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":"2022-01-20T07:09:13.000Z","updated_at":"2023-07-26T11:34:28.000Z","dependencies_parsed_at":"2023-02-09T23:00:24.788Z","dependency_job_id":null,"html_url":"https://github.com/zbh255/bilog","commit_stats":null,"previous_names":[],"tags_count":8,"template":null,"template_full_name":null,"purl":"pkg:github/zbh255/bilog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbh255%2Fbilog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbh255%2Fbilog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbh255%2Fbilog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbh255%2Fbilog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbh255","download_url":"https://codeload.github.com/zbh255/bilog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbh255%2Fbilog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","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":["go","golang","high-performance-logger","log-library","logger"],"created_at":"2026-01-17T01:24:38.298Z","updated_at":"2026-01-17T01:24:39.048Z","avatar_url":"https://github.com/zbh255.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bilog [![Go Report Card](https://goreportcard.com/badge/github.com/zbh255/bilog)](https://goreportcard.com/report/github.com/zbh255/bilog) ![GitHub](https://img.shields.io/github/license/zbh255/bilog) ![GitHub](https://github.com/zbh255/bilog/actions/workflows/go.yml/badge.svg) [![codecov](https://codecov.io/gh/zbh255/bilog/branch/main/graph/badge.svg?token=DKaQWjgsF8)](https://codecov.io/gh/zbh255/bilog) [![Go Doc](https://pkg.go.dev/badge/github.com/zbh255/bilog?utm_source=godoc)](https://pkg.go.dev/github.com/zbh255/bilog)\n\nbilog被设计为可以在需要性能，简单日志的场景下可以替换std log，它关注性能与轻量的实现。\n\n## Install\n\n```shell\ngo get github.com/zbh255/bilog\n```\n\n## Quick-Start\n\n\u003e 下面的所有示例代码都可在本`repo`的`example`文件夹中找到\n\n### Print-Time\n\n```go\nfunc main() {\n\tlogger := bilog.NewLogger(os.Stdout, bilog.PANIC)\n\tlogger.Debug(\"hello world\")\n\tlogger.Trace(\"hello world!\")\n\tlogger.Flush()\n}\n```\n\n`OutPut`\n\n```shell\n[DEBUG] 2022-01-24 12:53:29 hello world\n[TRACE] 2022-01-24 12:53:29 hello world!\n```\n\n### Print-Caller\n\n```go\nfunc main() {\n\tlogger := bilog.NewLogger(os.Stdout,bilog.PANIC,bilog.WithDefault(),bilog.WithCaller(0))\n\tlogger.Trace(\"hello world!\")\n\tlogger.Debug(\"hello world!\")\n\tlogger.Flush()\n}\n```\n\n`OutPut`\n\n```shell\n[TRACE] 2022-05-07 23:57:27 /Users/harder/Desktop/Git-Repo/github.com/zbh255/bilog/example/basic/caller/main.go:10 hello world!\n[DEBUG] 2022-05-07 23:57:27 /Users/harder/Desktop/Git-Repo/github.com/zbh255/bilog/example/basic/caller/main.go:11 hello world!\n```\n\n### No-Buffer\n\n`bilog`默认使用双重缓冲区来缓冲需要打印的`bytes`，您可以像上面的例子那样使用`Flush`强制刷新`Buffer`，也可以禁用缓冲，如下所示。\n\n```go\nfunc main() {\n\tlogger := bilog.NewLogger(os.Stdout,bilog.PANIC,bilog.WithDefault(),\n\t\tbilog.WithLowBuffer(0),bilog.WithTopBuffer(0))\n\tlogger.Trace(\"hello world!\")\n\tlogger.Info(\"hello world!\")\n}\n```\n\n`OutPut`\n\n```shell\n[TRACE] 2022-05-08 00:35:34  hello world!\n[INFO] 2022-05-08 00:35:34  hello world!\n```\n\n\u003e 事实上，您可以禁用缓冲也可以自行调节缓冲区的大小，使用跟如上示例一样的`Api`\n\n## Benchmark\n\nCpu: i7-8705G 4C/8T 的测试结果，测试用例在`log_test.go`\n\n```shell\ngoos: darwin\ngoarch: amd64\npkg: github.com/zbh255/bilog/benchmark\ncpu: Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz\nBenchmarkNoConcurrent\nBenchmarkNoConcurrent/Bilog-Buffer-1000\nBenchmarkNoConcurrent/Bilog-Buffer-1000-8         \t   30687\t     38321 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-Buffer-10000\nBenchmarkNoConcurrent/Bilog-Buffer-10000-8        \t    3160\t    371820 ns/op\t       1 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-Buffer-100000\nBenchmarkNoConcurrent/Bilog-Buffer-100000-8       \t     328\t   3586913 ns/op\t      17 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-Buffer-1000000\nBenchmarkNoConcurrent/Bilog-Buffer-1000000-8      \t      32\t  35836612 ns/op\t     173 B/op\t       6 allocs/op\nBenchmarkNoConcurrent/Bilog-NoBuffer-1000\nBenchmarkNoConcurrent/Bilog-NoBuffer-1000-8       \t   37311\t     31553 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-NoBuffer-10000\nBenchmarkNoConcurrent/Bilog-NoBuffer-10000-8      \t    3680\t    317317 ns/op\t       1 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-NoBuffer-100000\nBenchmarkNoConcurrent/Bilog-NoBuffer-100000-8     \t     376\t   3170883 ns/op\t      15 B/op\t       0 allocs/op\nBenchmarkNoConcurrent/Bilog-NoBuffer-1000000\nBenchmarkNoConcurrent/Bilog-NoBuffer-1000000-8    \t      34\t  31894623 ns/op\t     156 B/op\t       5 allocs/op\nBenchmarkNoConcurrent/Stdlog-NoBuffer-1000\nBenchmarkNoConcurrent/Stdlog-NoBuffer-1000-8      \t    3900\t    287960 ns/op\t   16007 B/op\t    1000 allocs/op\nBenchmarkNoConcurrent/Stdlog-NoBuffer-10000\nBenchmarkNoConcurrent/Stdlog-NoBuffer-10000-8     \t     382\t   2857697 ns/op\t  160069 B/op\t   10000 allocs/op\nBenchmarkNoConcurrent/Stdlog-NoBuffer-100000\nBenchmarkNoConcurrent/Stdlog-NoBuffer-100000-8    \t      40\t  28701547 ns/op\t 1600674 B/op\t  100007 allocs/op\nBenchmarkNoConcurrent/Stdlog-NoBuffer-1000000\nBenchmarkNoConcurrent/Stdlog-NoBuffer-1000000-8   \t       4\t 286931206 ns/op\t16006676 B/op\t 1000070 allocs/op\nBenchmarkConcurrent\nBenchmarkConcurrent/Bilog-Buffer-1000\nBenchmarkConcurrent/Bilog-Buffer-1000-8           \t    3792\t    323843 ns/op\t   24203 B/op\t    1002 allocs/op\nBenchmarkConcurrent/Bilog-Buffer-10000\nBenchmarkConcurrent/Bilog-Buffer-10000-8          \t     458\t   2735214 ns/op\t  249576 B/op\t   10094 allocs/op\nBenchmarkConcurrent/Bilog-Buffer-100000\nBenchmarkConcurrent/Bilog-Buffer-100000-8         \t      42\t  28385323 ns/op\t 2661977 B/op\t  101717 allocs/op\nBenchmarkConcurrent/Bilog-Buffer-1000000\nBenchmarkConcurrent/Bilog-Buffer-1000000-8        \t       4\t 279774264 ns/op\t25004370 B/op\t 1008890 allocs/op\nBenchmarkConcurrent/Bilog-NoBuffer-1000\nBenchmarkConcurrent/Bilog-NoBuffer-1000-8         \t    4624\t    286396 ns/op\t   24065 B/op\t    1001 allocs/op\nBenchmarkConcurrent/Bilog-NoBuffer-10000\nBenchmarkConcurrent/Bilog-NoBuffer-10000-8        \t     494\t   2411639 ns/op\t  242474 B/op\t   10026 allocs/op\nBenchmarkConcurrent/Bilog-NoBuffer-100000\nBenchmarkConcurrent/Bilog-NoBuffer-100000-8       \t      54\t  23822805 ns/op\t 2461564 B/op\t  100645 allocs/op\nBenchmarkConcurrent/Bilog-NoBuffer-1000000\nBenchmarkConcurrent/Bilog-NoBuffer-1000000-8      \t       5\t 233709438 ns/op\t24369846 B/op\t 1003884 allocs/op\nBenchmarkConcurrent/Stdlog-NoBuffer-1000\nBenchmarkConcurrent/Stdlog-NoBuffer-1000-8        \t     429\t   2856284 ns/op\t   40511 B/op\t    2006 allocs/op\nBenchmarkConcurrent/Stdlog-NoBuffer-10000\nBenchmarkConcurrent/Stdlog-NoBuffer-10000-8       \t      38\t  27950113 ns/op\t  439271 B/op\t   20407 allocs/op\nBenchmarkConcurrent/Stdlog-NoBuffer-100000\nBenchmarkConcurrent/Stdlog-NoBuffer-100000-8      \t       4\t 262928956 ns/op\t 6094424 B/op\t  221852 allocs/op\nBenchmarkConcurrent/Stdlog-NoBuffer-1000000\nBenchmarkConcurrent/Stdlog-NoBuffer-1000000-8     \t       1\t3148452471 ns/op\t420471352 B/op\t 3423558 allocs/op\nPASS\n```\n\n## Lisence\n\nThe Bilog Use Mit licensed. More is See [Lisence](https://github.com/zbh255/bilog/blob/main/LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbh255%2Fbilog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbh255%2Fbilog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbh255%2Fbilog/lists"}