{"id":20214214,"url":"https://github.com/masterminds/log-go","last_synced_at":"2025-04-10T14:08:16.192Z","repository":{"id":40298231,"uuid":"332068402","full_name":"Masterminds/log-go","owner":"Masterminds","description":"A Golang logging interface with some reference implementations.","archived":false,"fork":false,"pushed_at":"2023-04-25T09:22:25.000Z","size":91,"stargazers_count":21,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-24T12:48:02.958Z","etag":null,"topics":["golang","interface","logger","logging","logrus","zap"],"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/Masterminds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2021-01-22T21:39:05.000Z","updated_at":"2024-08-26T11:13:08.000Z","dependencies_parsed_at":"2024-06-18T18:40:56.888Z","dependency_job_id":"7c8ca9e1-b4ad-406f-97aa-1094ef2da771","html_url":"https://github.com/Masterminds/log-go","commit_stats":null,"previous_names":["mattfarina/log"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Flog-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Flog-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Flog-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masterminds%2Flog-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Masterminds","download_url":"https://codeload.github.com/Masterminds/log-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248232174,"owners_count":21069475,"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","interface","logger","logging","logrus","zap"],"created_at":"2024-11-14T06:14:39.913Z","updated_at":"2025-04-10T14:08:16.171Z","avatar_url":"https://github.com/Masterminds.png","language":"Go","readme":"# Log Package\n\nThe log package provides a common interface for logging that can be used in\napplications and libraries along with reference implementations for logrus, zap,\nthe Go standard library package, and for a CLI (console app).\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/log-go)](https://goreportcard.com/report/github.com/Masterminds/log-go)\n[![](https://github.com/Masterminds/semver/workflows/Tests/badge.svg)](https://github.com/Masterminds/log-go/actions)\n[![GoDoc](https://img.shields.io/static/v1?label=go.dev\u0026message=reference\u0026color=blue)](https://pkg.go.dev/github.com/Masterminds/log-go)\n\n## Why A Log Interface\n\nIn many programming languages there is a logging interface. Libraries will use\nuse the interface for logging and then the application will choose the logging\nlibrary of their choice for the application as a whole. Since everything follows\nthe interface it works.\n\nGo does not have a detailed interface. The logging package included in the\nstandard library has been insufficient so many logging libraries have been\ncreated.\n\nVarious libraries/packages use the a logging implementation of their choice.\nWhen those are pulled into a larger application is will end up having multiple\ndifferent logging systems. The main application needs to wire them all up or it\nwill miss some logs. If you take a look at applications like Kubernetes, Nomad,\nand many others you'll discover they import many different logging implementations.\n\nUsing interfaces provides a may to move away from multiple implementation,\nsimplify codebases, reduce binary size, and reduce threat surface area.\n\n## What This Package Provides\n\nThis library includes several things including:\n\n- A Go interface for leveled logging. Those levels include - Fatal, Panic, Error,\n  Warn, Info, Debug, Trace\n- When logging messages the interface can do a message, a message with formatting\n  string and arguments, and a message with fields (key/value pairs)\n- Package level logging functions whose implementation can be changed/set\n- Reference implementations for logrus, zap, the standard library, and a CLI\n- A simple default implementation so it just works for library testing and\n  simple situations\n\n## Usage\n\nThe usage documentation is broken down into 3 types of usage depending on your\nsituation. These examples are for library/package authors, applications, and\nlogger implementation developers.\n\n### Library / Package Authors\n\nIf you are a library or package author there are two ways you can use this log\npackage.\n\nFirst, you can import the package and use the package level logging options. For\nexample:\n\n```go\nimport(\n    \"github.com/Masterminds/log-go\"\n)\n\nlog.Info(\"Send Some Info\")\n```\n\nYou can use this for logging within your package.\n\nSecond, if you want to pass a logger around your package you can use the\ninterface provided by this package. For example:\n\n```go\nimport \"github.com/Masterminds/log-go\"\n\nfunc NewConstructorExample(logger log.Logger) {\n    return \u0026Example{\n        logger: logger,\n    }\n}\n\nfunc (e *Example) Foo() {\n    e.logger.Info(\"Send Some Info\")\n}\n\n```\n\nIn your packages testing you can check log messages if you need to see that they\nare working and contain what you are looking for. A simple example of doing this\nis in the `_examples` directory.\n\nFor details on exactly which functions are on the package or on the `Logger`\ninterface, please see the [package docs](https://pkg.go.dev/github.com/Masterminds/log-go).\n\n### Application Developers\n\nIf you are developing an application that will be writing logs you will want to\nsetup and configure logging the way you want. This is where this interface\nbased package empowers you. You can pick your logging implementation or write\nyour own.\n\nFor example, if you want to use a standard logrus logger you can setup logging\nlike so:\n\n```go\nimport(\n    \"github.com/Masterminds/log-go\"\n    \"github.com/Masterminds/log-go/impl/logrus\"\n)\n\nlog.Current = logrus.NewStandard()\n```\n\nIn this example a standard logrus logger is created, wrapped in a struct\ninstance that conforms to the interface, and is set as the global logger to use.\n\nThe `impl` directory has several reference implementations and they have\nconfigurable setups.\n\nOnce you setup the global logger the way you want all the packages will use this\nsame logger.\n\n### Logger Developers\n\nThere are many loggers and many ways to record logs. They can be written to a\nfile, sent to stdout/stderr, sent to a logging service, and more. Each of these\nis possible with this package.\n\nIf you have logger you want to use you can write one that conforms to the\n`Logger` interface found in `log.go`. That logger can then be configured as\ndocumented in the previous section.\n\nThe `impl` directory has reference implementations you can look at for further\nexamples.\n\n## Log Levels\n\nThe following log levels are currently implemented across the interface and all\nthe reference implementations.\n\n- Fatal\n- Panic\n- Error\n- Warn\n- Info\n- Debug\n- Trace\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterminds%2Flog-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasterminds%2Flog-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterminds%2Flog-go/lists"}