{"id":21951877,"url":"https://github.com/go-coldbrew/log","last_synced_at":"2026-04-01T19:07:26.749Z","repository":{"id":40487225,"uuid":"327945538","full_name":"go-coldbrew/log","owner":"go-coldbrew","description":"log provides a minimal interface for structured logging in services. It provides a simple interface to log errors, warnings, info and debug messages. It also provides a mechanism to add contextual information to logs. We provide implementations for gokit, logrus and zap.","archived":false,"fork":false,"pushed_at":"2026-03-20T02:33:01.000Z","size":93,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-20T17:29:47.362Z","etag":null,"topics":["golang","logger","logging","microservice"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-coldbrew.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-08T15:50:15.000Z","updated_at":"2026-03-20T02:32:34.000Z","dependencies_parsed_at":"2025-03-22T18:11:36.620Z","dependency_job_id":"580783f9-bc6a-4cff-b4af-06dfc1e3e350","html_url":"https://github.com/go-coldbrew/log","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/go-coldbrew/log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-coldbrew%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-coldbrew%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-coldbrew%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-coldbrew%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-coldbrew","download_url":"https://codeload.github.com/go-coldbrew/log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-coldbrew%2Flog/sbom","scorecard":{"id":431551,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-coldbrew/log","commit":"24fdc69981b30a1a62f3df96ea96cda4dd487f6a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"name":"Code-Review","score":2,"reason":"Found 3/12 approved changesets -- score normalized to 2","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"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":"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":"Maintained","score":0,"reason":"1 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":10,"reason":"no dangerous workflow patterns detected","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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/go-coldbrew/log/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/go-coldbrew/log/go.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"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":"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: Apache License 2.0: 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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 1 commits out of 15 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-19T03:28:06.014Z","repository_id":40487225,"created_at":"2025-08-19T03:28:06.014Z","updated_at":"2025-08-19T03:28:06.014Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: 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":["golang","logger","logging","microservice"],"created_at":"2024-11-29T06:18:01.612Z","updated_at":"2026-04-01T19:07:26.732Z","avatar_url":"https://github.com/go-coldbrew.png","language":"Go","readme":"\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n[![CI](https://github.com/go-coldbrew/log/actions/workflows/go.yml/badge.svg)](https://github.com/go-coldbrew/log/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-coldbrew/log)](https://goreportcard.com/report/github.com/go-coldbrew/log)\n[![GoDoc](https://pkg.go.dev/badge/github.com/go-coldbrew/log.svg)](https://pkg.go.dev/github.com/go-coldbrew/log)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\n\n# log\n\n```go\nimport \"github.com/go-coldbrew/log\"\n```\n\nPackage log provides a minimal interface for structured logging in services. ColdBrew uses this log package for all logs. It provides a simple interface to log errors, warnings, info and debug messages. It also provides a mechanism to add contextual information to logs. available implementations of BaseLogger are in loggers package. You can also implement your own BaseLogger to use with this package.\n\n### How To Use\n\nThe simplest way to use this package is by calling static log functions to report particular level \\(error/warning/info/debug\\)\n\n```\nlog.Error(...)\nlog.Warn(...)\nlog.Info(...)\nlog.Debug(...)\n```\n\nYou can also initialize a new logger by calling 'log.NewLogger' and passing a loggers.BaseLogger implementation \\(loggers package provides a number of pre built implementations\\)\n\n```\nlogger := log.NewLogger(gokit.NewLogger())\nlogger.Info(ctx, \"key\", \"value\")\n```\n\nNote:\n\n```\nPreferred logging output is in either logfmt or json format, so to facilitate these log function arguments should be in pairs of key-value\n```\n\n### Contextual Logs\n\nlog package uses context.Context to pass additional information to logs, you can use 'loggers.AddToLogContext' function to add additional information to logs. For example in access log from service\n\n```\n{\"@timestamp\":\"2018-07-30T09:58:18.262948679Z\",\"caller\":\"http/http.go:66\",\"error\":null,\"grpcMethod\":\"/AuthSvc.AuthService/Authenticate\",\"level\":\"info\",\"method\":\"POST\",\"path\":\"/2.0/authenticate/\",\"took\":\"1.356812ms\",\"trace\":\"15592e1b-93df-11e8-bdfd-0242ac110002\",\"transport\":\"http\"}\n```\n\nwe pass 'grpcMethod' from context, this information gets automatically added to all log calls called inside the service and makes debugging services much easier. ColdBrew also generates a 'trace' ID per request, this can be used to trace an entire request path in logs.\n\nthis package is based on https://github.com/carousell/Orion/tree/master/utils/log\n\n## Index\n\n- [Constants](\u003c#constants\u003e)\n- [func AddToContext\\(ctx context.Context, key string, value any\\) context.Context](\u003c#AddToContext\u003e)\n- [func Debug\\(ctx context.Context, args ...any\\)](\u003c#Debug\u003e)\n- [func Error\\(ctx context.Context, args ...any\\)](\u003c#Error\u003e)\n- [func GetLevel\\(\\) loggers.Level](\u003c#GetLevel\u003e)\n- [func GetOverridenLogLevel\\(ctx context.Context\\) \\(loggers.Level, bool\\)](\u003c#GetOverridenLogLevel\u003e)\n- [func Info\\(ctx context.Context, args ...any\\)](\u003c#Info\u003e)\n- [func OverrideLogLevel\\(ctx context.Context, level loggers.Level\\) context.Context](\u003c#OverrideLogLevel\u003e)\n- [func SetLevel\\(level loggers.Level\\)](\u003c#SetLevel\u003e)\n- [func SetLogger\\(l Logger\\)](\u003c#SetLogger\u003e)\n- [func Warn\\(ctx context.Context, args ...any\\)](\u003c#Warn\u003e)\n- [type Logger](\u003c#Logger\u003e)\n  - [func GetLogger\\(\\) Logger](\u003c#GetLogger\u003e)\n  - [func NewLogger\\(log loggers.BaseLogger\\) Logger](\u003c#NewLogger\u003e)\n\n\n## Constants\n\n\u003ca name=\"SupportPackageIsVersion1\"\u003e\u003c/a\u003eSupportPackageIsVersion1 is a compile\\-time assertion constant. Downstream packages reference this to enforce version compatibility.\n\n```go\nconst SupportPackageIsVersion1 = true\n```\n\n\u003ca name=\"AddToContext\"\u003e\u003c/a\u003e\n## func [AddToContext](\u003chttps://github.com/go-coldbrew/log/blob/main/log.go#L93\u003e)\n\n```go\nfunc AddToContext(ctx context.Context, key string, value any) context.Context\n```\n\nAddToContext adds log fields to the provided context. Any info added here will be included in all logs that use the returned context. This is the preferred entry point for adding contextual logging fields and is implemented internally using loggers.AddToLogContext.\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-coldbrew/log\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\n\t// Add per-request fields to context — these appear in all subsequent log lines\n\tctx = log.AddToContext(ctx, \"request_id\", \"abc-123\")\n\tctx = log.AddToContext(ctx, \"user_id\", \"user-42\")\n\n\t// All logs using this context now include request_id and user_id\n\tlog.Info(ctx, \"msg\", \"processing request\", \"step\", \"validation\")\n\tlog.Info(ctx, \"msg\", \"request complete\", \"status\", \"ok\", \"duration_ms\", 42)\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"Debug\"\u003e\u003c/a\u003e\n## func [Debug](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L22\u003e)\n\n```go\nfunc Debug(ctx context.Context, args ...any)\n```\n\nDebug writes out a debug log to global logger This is a convenience function for GetLogger\\(\\).Log\\(ctx, loggers.DebugLevel, 1, args...\\)\n\n\u003ca name=\"Error\"\u003e\u003c/a\u003e\n## func [Error](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L40\u003e)\n\n```go\nfunc Error(ctx context.Context, args ...any)\n```\n\nError writes out an error log to global logger This is a convenience function for GetLogger\\(\\).Log\\(ctx, loggers.ErrorLevel, 1, args...\\)\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-coldbrew/log\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tlog.Error(ctx, \"msg\", \"database connection failed\", \"host\", \"db.internal\", \"port\", 5432, \"retry_in\", \"5s\")\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"GetLevel\"\u003e\u003c/a\u003e\n## func [GetLevel](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L16\u003e)\n\n```go\nfunc GetLevel() loggers.Level\n```\n\nGetLevel returns the current log level This is useful for checking if a log level is enabled\n\n\u003ca name=\"GetOverridenLogLevel\"\u003e\u003c/a\u003e\n## func [GetOverridenLogLevel](\u003chttps://github.com/go-coldbrew/log/blob/main/options.go#L26\u003e)\n\n```go\nfunc GetOverridenLogLevel(ctx context.Context) (loggers.Level, bool)\n```\n\nGetOverridenLogLevel fetches overriden log level from context If no log level is overriden, it returns false If log level is overriden, it returns the log level and true\n\n\u003ca name=\"Info\"\u003e\u003c/a\u003e\n## func [Info](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L28\u003e)\n\n```go\nfunc Info(ctx context.Context, args ...any)\n```\n\nInfo writes out an info log to global logger This is a convenience function for GetLogger\\(\\).Log\\(ctx, loggers.InfoLevel, 1, args...\\)\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-coldbrew/log\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tlog.Info(ctx, \"msg\", \"order processed\", \"order_id\", \"ORD-123\", \"items\", 3)\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"OverrideLogLevel\"\u003e\u003c/a\u003e\n## func [OverrideLogLevel](\u003chttps://github.com/go-coldbrew/log/blob/main/options.go#L19\u003e)\n\n```go\nfunc OverrideLogLevel(ctx context.Context, level loggers.Level) context.Context\n```\n\nOverrideLogLevel allows the default log level to be overridden from request context This is useful when you want to override the log level for a specific request For example, you can set the log level to debug for a specific request while the default log level is set to info\n\n\u003ca name=\"SetLevel\"\u003e\u003c/a\u003e\n## func [SetLevel](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L10\u003e)\n\n```go\nfunc SetLevel(level loggers.Level)\n```\n\nSetLevel sets the log level to filter logs\n\n\u003ca name=\"SetLogger\"\u003e\u003c/a\u003e\n## func [SetLogger](\u003chttps://github.com/go-coldbrew/log/blob/main/log.go#L83\u003e)\n\n```go\nfunc SetLogger(l Logger)\n```\n\nSetLogger sets the global logger\n\n\u003ca name=\"Warn\"\u003e\u003c/a\u003e\n## func [Warn](\u003chttps://github.com/go-coldbrew/log/blob/main/utils.go#L34\u003e)\n\n```go\nfunc Warn(ctx context.Context, args ...any)\n```\n\nWarn writes out a warning log to global logger This is a convenience function for GetLogger\\(\\).Log\\(ctx, loggers.WarnLevel, 1, args...\\)\n\n\u003ca name=\"Logger\"\u003e\u003c/a\u003e\n## type [Logger](\u003chttps://github.com/go-coldbrew/log/blob/main/types.go#L10-L24\u003e)\n\nLogger interface is implemnted by the log implementation to provide the log methods to the application code.\n\n```go\ntype Logger interface {\n    loggers.BaseLogger\n    // Debug logs a message at level Debug.\n    // ctx is used to extract the request id and other context information.\n    Debug(ctx context.Context, args ...any)\n    // Info logs a message at level Info.\n    // ctx is used to extract the request id and other context information.\n    Info(ctx context.Context, args ...any)\n    // Warn logs a message at level Warn.\n    // ctx is used to extract the request id and other context information.\n    Warn(ctx context.Context, args ...any)\n    // Error logs a message at level Error.\n    // ctx is used to extract the request id and other context information.\n    Error(ctx context.Context, args ...any)\n}\n```\n\n\u003ca name=\"GetLogger\"\u003e\u003c/a\u003e\n### func [GetLogger](\u003chttps://github.com/go-coldbrew/log/blob/main/log.go#L71\u003e)\n\n```go\nfunc GetLogger() Logger\n```\n\nGetLogger returns the global logger If the global logger is not set, it will create a new one with slog logger\n\n\u003ca name=\"NewLogger\"\u003e\u003c/a\u003e\n### func [NewLogger](\u003chttps://github.com/go-coldbrew/log/blob/main/log.go#L63\u003e)\n\n```go\nfunc NewLogger(log loggers.BaseLogger) Logger\n```\n\nNewLogger creates a new logger with a provided BaseLogger The default logger is slog logger\n\nGenerated by [gomarkdoc](\u003chttps://github.com/princjef/gomarkdoc\u003e)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-coldbrew%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-coldbrew%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-coldbrew%2Flog/lists"}