{"id":19292445,"url":"https://github.com/werf/logboek","last_synced_at":"2025-04-22T07:31:46.387Z","repository":{"id":52962671,"uuid":"176729701","full_name":"werf/logboek","owner":"werf","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-29T11:50:08.000Z","size":202,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-20T02:13:39.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/werf.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}},"created_at":"2019-03-20T12:33:08.000Z","updated_at":"2024-03-06T02:08:04.000Z","dependencies_parsed_at":"2023-12-29T12:48:28.954Z","dependency_job_id":null,"html_url":"https://github.com/werf/logboek","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werf%2Flogboek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werf%2Flogboek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werf%2Flogboek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werf%2Flogboek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/werf","download_url":"https://codeload.github.com/werf/logboek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223892159,"owners_count":17220720,"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":[],"created_at":"2024-11-09T22:30:57.064Z","updated_at":"2025-04-22T07:31:46.380Z","avatar_url":"https://github.com/werf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## logboek — a library for structured and informative output\n\n### Logger, channels, and streams\n\n\u003cimg src=\"https://github.com/werf/logboek/blob/master/logger.png?raw=true\"\u003e\n\nWhen creating a logger, you need to specify the **streams**, `OutStream` and `ErrStream`, which must adhere to the `io.Writer` interface (this can be a file, standard output streams, a buffer, or any custom implementation):\n\n```go\nimport \"github.com/werf/logboek\"\n\n// NewLogger(outStream, errStream io.Writer) *Logger\nl := logboek.NewLogger(os.Stdout, os.Stderr)\n```\n\nStream settings allow you to define formatting parameters such as prefix and tag, as well as various modes of operation. These settings apply to both `OutStream` and `ErrStream`, and consequently to all channels that will be discussed later.\n\n```go\nl.Streams()\n```\n\nThe logger is connected to the **log channels** `Error`, `Warn`, `Default`, `Info`, and `Debug`. When using the `Error` and `Warn` channels, all messages are written to `ErrStream`, while for the others, they go to `OutStream`.\n\nLog channels allow you to organize the output for various application modes (verbose and debug modes), branch execution, and control flow depending on the active channel (activating a channel also triggers output to lower-priority channels):\n\n```go\nimport (\n    \"github.com/werf/logboek\"\n    \"github.com/werf/logboek/pkg/level\"\n)\n\nswitch mode {\ncase \"verbose\":\n    l.SetAcceptedLevel(level.Info)\ncase \"debug\":\n    l.SetAcceptedLevel(level.Debug)\ncase \"quiet\":\n    l.SetAcceptedLevel(level.Error)  \n}\n\n...\n\nif l.Debug().IsAccepted() {\n  ... // do and print something special\n}\n```\n\nIf channels are not required, you can simply use the `Default` channel, whose methods are available at the top level of the logger:\n\n```go\nl.LogLn() // l.Default().LogLn()\nl.LogF()  // l.Default().LogF()\n...\n```\n\n\u003c!---\n- Terminal width\n- Inherited settings\n- Proxy\n--\u003e\n\n### Default logger\n\nBy default, the library initializes the `DefaultLogger` with preset streams `os.Stdout` and `os.Stderr`. You can interact with the logger using the instance itself or the high-level library functions that correspond to all available logger methods:\n\n```go\nimport \"github.com/werf/logboek\"\n\nlogboek.DefaultLogger()\n\nlogboek.Default() // logboek.DefaultLogger().Default()\nlogboek.LogLn()   // logboek.DefaultLogger().LogLn()\nlogboek.Streams() // logboek.DefaultLogger().Streams()\n...\n```\n\n\u003c!---\n## Logging Methods\n\n\u003cimg align=\"right\" src=\"https://github.com/werf/logboek/blob/master/logboek.png?raw=true\"\u003e\n--\u003e\n\n\u003c!---\n## Processes and blocks\n## Prefix and tag\n## Modes\n- isMuted                            \n- isStyleEnabled                     \n- isLineWrappingEnabled              \n- isProxyStreamDataFormattingEnabled \n- isGitlabCollapsibleSectionsEnabled \n- isPrefixWithTimeEnabled            \n- isLogProcessBorderEnabled \n## Using in external libraries\n## Using in go-routines\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerf%2Flogboek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerf%2Flogboek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerf%2Flogboek/lists"}