{"id":16179783,"url":"https://github.com/bep/logg","last_synced_at":"2025-10-29T02:49:50.480Z","repository":{"id":54351325,"uuid":"522184630","full_name":"bep/logg","owner":"bep","description":"A Fast and Structured logging package for Go.","archived":false,"fork":false,"pushed_at":"2023-11-06T09:03:08.000Z","size":240,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-27T07:40:29.213Z","etag":null,"topics":["golang","log","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"apex/log","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["bep"]}},"created_at":"2022-08-07T10:44:16.000Z","updated_at":"2025-02-24T22:09:51.000Z","dependencies_parsed_at":"2023-11-06T10:25:31.191Z","dependency_job_id":"1aa64cdc-186e-48e6-aa81-08a0d3ed4b3d","html_url":"https://github.com/bep/logg","commit_stats":null,"previous_names":["bep/log"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Flogg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Flogg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Flogg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Flogg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bep","download_url":"https://codeload.github.com/bep/logg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243810903,"owners_count":20351616,"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":["golang","log","logging"],"created_at":"2024-10-10T05:44:00.383Z","updated_at":"2025-10-29T02:49:45.461Z","avatar_url":"https://github.com/bep.png","language":"Go","funding_links":["https://github.com/sponsors/bep"],"categories":[],"sub_categories":[],"readme":"\n[![Tests on Linux, MacOS and Windows](https://github.com/bep/logg/workflows/Test/badge.svg)](https://github.com/bep/logg/actions?query=workflow:Test)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bep/logg)](https://goreportcard.com/report/github.com/bep/logg)\n[![GoDoc](https://godoc.org/github.com/bep/logg?status.svg)](https://godoc.org/github.com/bep/logg)\n\nThis is a fork of the exellent [Apex Log](https://github.com/apex/log) library.\n\nMain changes:\n\n* Trim unneeded dependencies.\n* Make `Fields` into a slice to preserve log order.\n* Split the old `Interface` in two and remove all but one `Log` method (see below).\n* This allows for lazy creation of messages in `Log(fmt.Stringer)` and ignoring fields added in `LevelLogger`s with levels below the `Logger`s.\n* The pointer passed to `HandleLog` is not safe to use outside of the current log chain, and needs to be cloned with `Clone` first if that's needed.\n* See [Benchmarks](#benchmarks) for more info.\n\nThis is probably the very fastest structured log library when logging is disabled:\n\n\u003cimg width=\"492\" alt=\"image\" src=\"https://user-images.githubusercontent.com/394382/184383985-265a4b0e-ee36-405e-9dc1-4686d0cad57a.png\"\u003e\n\n\u003e One can never have enough log libraries!\n\n```go\n// Logger is the main interface for the logger.\ntype Logger interface {\n\t// WithLevel returns a new entry with `level` set.\n\tWithLevel(Level) *Entry\n}\n\n// LevelLogger is the logger at a given level.\ntype LevelLogger interface {\n\t// Log logs a message at the given level using the string from calling s.String().\n\t// Note that s.String() will not be called if the level is not enabled.\n\tLog(s fmt.Stringer)\n\n\t// Logf logs a message at the given level using the format and args from calling fmt.Sprintf().\n\t// Note that fmt.Sprintf() will not be called if the level is not enabled.\n\tLogf(format string, a ...any)\n\n\t// WithLevel returns a new entry with `level` set.\n\tWithLevel(Level) *Entry\n\n\t// WithFields returns a new entry with the`fields` in fields set.\n\t// This is a noop if LevelLogger's level is less than Logger's.\n\tWithFields(fields Fielder) *Entry\n\n\t// WithLevel returns a new entry with the field f set with value v\n\t// This is a noop if LevelLogger's level is less than Logger's.\n\tWithField(f string, v any) *Entry\n\n\t// WithDuration returns a new entry with the \"duration\" field set\n\t// to the given duration in milliseconds.\n\t// This is a noop if LevelLogger's level is less than Logger's.\n\tWithDuration(time.Duration) *Entry\n\n\t// WithError returns a new entry with the \"error\" set to `err`.\n\t// This is a noop if err is nil or  LevelLogger's level is less than Logger's.\n\tWithError(error) *Entry\n}\n```\n\n## Benchmarks\n\nBenchmarks below are borrowed and adapted from [Zap](https://github.com/uber-go/zap/tree/master/benchmarks).\n\n### Logging at a disabled level without any structured context\n\n```\nname                                      time/op\nDisabledWithoutFields/apex/log-10         33.9ns ± 0%\nDisabledWithoutFields/bep/logg-10         0.28ns ± 0%\nDisabledWithoutFields/sirupsen/logrus-10  6.54ns ± 0%\nDisabledWithoutFields/rs/zerolog-10       0.31ns ± 0%\n\nname                                      alloc/op\nDisabledWithoutFields/apex/log-10           112B ± 0%\nDisabledWithoutFields/bep/logg-10          0.00B\nDisabledWithoutFields/sirupsen/logrus-10   16.0B ± 0%\nDisabledWithoutFields/rs/zerolog-10        0.00B\n\nname                                      allocs/op\nDisabledWithoutFields/apex/log-10           1.00 ± 0%\nDisabledWithoutFields/bep/logg-10           0.00\nDisabledWithoutFields/sirupsen/logrus-10    1.00 ± 0%\nDisabledWithoutFields/rs/zerolog-10         0.00\n```\n\n\n### Logging at a disabled level with some accumulated context\n\n```\nname                                           time/op\nDisabledAccumulatedContext/apex/log-10         0.29ns ± 0%\nDisabledAccumulatedContext/bep/logg-10         0.27ns ± 0%\nDisabledAccumulatedContext/sirupsen/logrus-10  6.61ns ± 0%\nDisabledAccumulatedContext/rs/zerolog-10       0.32ns ± 0%\n\nname                                           alloc/op\nDisabledAccumulatedContext/apex/log-10          0.00B\nDisabledAccumulatedContext/bep/logg-10          0.00B\nDisabledAccumulatedContext/sirupsen/logrus-10   16.0B ± 0%\nDisabledAccumulatedContext/rs/zerolog-10        0.00B\n\nname                                           allocs/op\nDisabledAccumulatedContext/apex/log-10           0.00\nDisabledAccumulatedContext/bep/logg-10           0.00\nDisabledAccumulatedContext/sirupsen/logrus-10    1.00 ± 0%\nDisabledAccumulatedContext/rs/zerolog-10         0.00\n```\n\n### Logging at a disabled level, adding context at each log site\n\n```\nname                                     time/op\nDisabledAddingFields/apex/log-10          328ns ± 0%\nDisabledAddingFields/bep/logg-10         0.38ns ± 0%\nDisabledAddingFields/sirupsen/logrus-10   610ns ± 0%\nDisabledAddingFields/rs/zerolog-10       10.5ns ± 0%\n\nname                                     alloc/op\nDisabledAddingFields/apex/log-10           886B ± 0%\nDisabledAddingFields/bep/logg-10          0.00B\nDisabledAddingFields/sirupsen/logrus-10  1.52kB ± 0%\nDisabledAddingFields/rs/zerolog-10        24.0B ± 0%\n\nname                                     allocs/op\nDisabledAddingFields/apex/log-10           10.0 ± 0%\nDisabledAddingFields/bep/logg-10           0.00\nDisabledAddingFields/sirupsen/logrus-10    12.0 ± 0%\nDisabledAddingFields/rs/zerolog-10         1.00 ± 0%\n```\n\n### Logging without any structured context\n\n```\nname                                    time/op\nWithoutFields/apex/log-10                964ns ± 0%\nWithoutFields/bep/logg-10                100ns ± 0%\nWithoutFields/go-kit/kit/log-10          232ns ± 0%\nWithoutFields/inconshreveable/log15-10  2.13µs ± 0%\nWithoutFields/sirupsen/logrus-10         866ns ± 0%\nWithoutFields/stdlib.Println-10         7.08ns ± 0%\nWithoutFields/stdlib.Printf-10          56.4ns ± 0%\nWithoutFields/rs/zerolog-10             30.9ns ± 0%\nWithoutFields/rs/zerolog.Formatting-10  1.33µs ± 0%\nWithoutFields/rs/zerolog.Check-10       32.1ns ± 0%\n\nname                                    alloc/op\nWithoutFields/apex/log-10                 352B ± 0%\nWithoutFields/bep/logg-10                56.0B ± 0%\nWithoutFields/go-kit/kit/log-10           520B ± 0%\nWithoutFields/inconshreveable/log15-10  1.43kB ± 0%\nWithoutFields/sirupsen/logrus-10        1.14kB ± 0%\nWithoutFields/stdlib.Println-10          16.0B ± 0%\nWithoutFields/stdlib.Printf-10            136B ± 0%\nWithoutFields/rs/zerolog-10              0.00B\nWithoutFields/rs/zerolog.Formatting-10  1.92kB ± 0%\nWithoutFields/rs/zerolog.Check-10        0.00B\n\nname                                    allocs/op\nWithoutFields/apex/log-10                 6.00 ± 0%\nWithoutFields/bep/logg-10                 2.00 ± 0%\nWithoutFields/go-kit/kit/log-10           9.00 ± 0%\nWithoutFields/inconshreveable/log15-10    20.0 ± 0%\nWithoutFields/sirupsen/logrus-10          23.0 ± 0%\nWithoutFields/stdlib.Println-10           1.00 ± 0%\nWithoutFields/stdlib.Printf-10            6.00 ± 0%\nWithoutFields/rs/zerolog-10               0.00\nWithoutFields/rs/zerolog.Formatting-10    58.0 ± 0%\nWithoutFields/rs/zerolog.Check-10         0.00\n```\n\n\n### Logging with some accumulated context\n\n```\nname                                         time/op\nAccumulatedContext/apex/log-10               12.7µs ± 0%\nAccumulatedContext/bep/logg-10               1.52µs ± 0%\nAccumulatedContext/go-kit/kit/log-10         2.52µs ± 0%\nAccumulatedContext/inconshreveable/log15-10  9.36µs ± 0%\nAccumulatedContext/sirupsen/logrus-10        3.41µs ± 0%\nAccumulatedContext/rs/zerolog-10             37.9ns ± 0%\nAccumulatedContext/rs/zerolog.Check-10       34.0ns ± 0%\nAccumulatedContext/rs/zerolog.Formatting-10  1.36µs ± 0%\n\nname                                         alloc/op\nAccumulatedContext/apex/log-10               3.30kB ± 0%\nAccumulatedContext/bep/logg-10               1.16kB ± 0%\nAccumulatedContext/go-kit/kit/log-10         3.67kB ± 0%\nAccumulatedContext/inconshreveable/log15-10  3.31kB ± 0%\nAccumulatedContext/sirupsen/logrus-10        4.73kB ± 0%\nAccumulatedContext/rs/zerolog-10              0.00B\nAccumulatedContext/rs/zerolog.Check-10        0.00B\nAccumulatedContext/rs/zerolog.Formatting-10  1.92kB ± 0%\n\nname                                         allocs/op\nAccumulatedContext/apex/log-10                 53.0 ± 0%\nAccumulatedContext/bep/logg-10                 25.0 ± 0%\nAccumulatedContext/go-kit/kit/log-10           56.0 ± 0%\nAccumulatedContext/inconshreveable/log15-10    70.0 ± 0%\nAccumulatedContext/sirupsen/logrus-10          68.0 ± 0%\nAccumulatedContext/rs/zerolog-10               0.00\nAccumulatedContext/rs/zerolog.Check-10         0.00\nAccumulatedContext/rs/zerolog.Formatting-10    58.0 ± 0%\n```\n\n\n## Logging with additional context at each log site\n\n```\nname                                   time/op\nAddingFields/apex/log-10               13.2µs ± 0%\nAddingFields/bep/logg-10               1.79µs ± 0%\nAddingFields/go-kit/kit/log-10         2.23µs ± 0%\nAddingFields/inconshreveable/log15-10  14.3µs ± 0%\nAddingFields/sirupsen/logrus-10        4.46µs ± 0%\nAddingFields/rs/zerolog-10              398ns ± 0%\nAddingFields/rs/zerolog.Check-10        389ns ± 0%\n\nname                                   alloc/op\nAddingFields/apex/log-10               4.19kB ± 0%\nAddingFields/bep/logg-10               2.02kB ± 0%\nAddingFields/go-kit/kit/log-10         3.31kB ± 0%\nAddingFields/inconshreveable/log15-10  6.68kB ± 0%\nAddingFields/sirupsen/logrus-10        6.27kB ± 0%\nAddingFields/rs/zerolog-10              24.0B ± 0%\nAddingFields/rs/zerolog.Check-10        24.0B ± 0%\n\nname                                   allocs/op\nAddingFields/apex/log-10                 63.0 ± 0%\nAddingFields/bep/logg-10                 34.0 ± 0%\nAddingFields/go-kit/kit/log-10           57.0 ± 0%\nAddingFields/inconshreveable/log15-10    74.0 ± 0%\nAddingFields/sirupsen/logrus-10          79.0 ± 0%\nAddingFields/rs/zerolog-10               1.00 ± 0%\nAddingFields/rs/zerolog.Check-10         1.00 ± 0%\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Flogg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbep%2Flogg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Flogg/lists"}