{"id":22361725,"url":"https://github.com/foresthoffman/loggy","last_synced_at":"2025-06-17T19:04:05.893Z","repository":{"id":50883444,"uuid":"365632226","full_name":"foresthoffman/loggy","owner":"foresthoffman","description":"A Go logging package with customizable verbosity. Letting you hack through those logs and see only the information you need. 🌲🪓","archived":false,"fork":false,"pushed_at":"2023-03-29T20:53:27.000Z","size":31,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T14:52:22.183Z","etag":null,"topics":["go","golang","logging"],"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/foresthoffman.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":"2021-05-08T23:48:31.000Z","updated_at":"2023-04-06T18:22:13.000Z","dependencies_parsed_at":"2024-06-21T08:53:20.672Z","dependency_job_id":null,"html_url":"https://github.com/foresthoffman/loggy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/foresthoffman/loggy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Floggy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Floggy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Floggy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Floggy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foresthoffman","download_url":"https://codeload.github.com/foresthoffman/loggy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foresthoffman%2Floggy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260424571,"owners_count":23007035,"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":["go","golang","logging"],"created_at":"2024-12-04T16:32:33.194Z","updated_at":"2025-06-17T19:04:00.879Z","avatar_url":"https://github.com/foresthoffman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌲 Loggy 🌲\n\n![Current project build status](https://github.com/foresthoffman/loggy/actions/workflows/go.yml/badge.svg)\n\nLoggy wraps the standard log.Logger structure with some additional fields, to standardize stdout and stderr output. Based on the \"severity\" of any given log, loggy redirects logs to stdout while redirecting errors to stderr. The desired logging level, or \"threshold\", shared between the two output streams filters the output messages. If a log or error message doesn't fall on or under the desired threshold, then that message is ignored. Messages with the \"standard\" severity are always displayed.\n\n### Installation\n\nRun `go get -u github.com/foresthoffman/loggy`\n\nIf you're using `go mod`, run `go mod vendor` afterwards.\n\n### Importing\n\nImport this package by including `github.com/foresthoffman/loggy` in your import block.\n\ne.g.\n\n```go\npackage main\n\nimport(\n    ...\n    \"github.com/foresthoffman/loggy\"\n)\n```\n\n### Log Levels\n\nThe logger's `Threshold` is an integer that determines what severities (e.g. \"log levels\") are output and which are ignored. Users may assign whatever context and importance they deem fit to the log levels; however, Critical-level and Warning-level logs will be output to the provided stderr regardless. In descending order the available log levels are:\n\n- Standard\n  - Labeled \"OUT\".\n  - Typically, just standard output of no particular importance.\n- Critical\n  - Labeled \"CRIT\".\n  - Typically, indicates a fatal issue.\n- Error\n  - Labeled \"ERROR\".\n  - Typically, indicates a general issue that was recovered.\n- Warning\n  - Labeled \"WARN\".\n  - Typically, indicates an issue that may require intervention.\n- Info\n  - Labeled \"INFO\".\n  - Typically, indicates generic runtime information.\n- Debug\n  - Labeled \"DEBUG\".\n  - Typically, indicates debug output.\n\nFor example, with a threshold of `LevelCritical`, only logs the following severities would be output:\n\n- Standard\n  - Sent to stdout.\n- Critical\n  - Sent to stderr.\n\nLikewise, if the threshold was `LevelInfo`, all logs would be output except for those with a severity of Debug.\n\n### Disabling Logging\n\nProviding a `Logger.Threshold` \u003c 0 will disable logging entirely. This behaves similarly to a standard `--quiet` CLI flag.\n\n### Usage\n\n```go\npackage main\n\nimport (\n  \"bytes\"\n  \"context\"\n  \"errors\"\n  \"fmt\"\n  \"github.com/foresthoffman/loggy\"\n)\n\nfunc main() {\n  // - Use OS stdout/stderr by default.\n  // - Only show messages that are critical or standard.\n  // - Custom prefix, prepended to each message before the timestamp.\n  options := loggy.Options{\n    Prefix: \"~~~\",\n    Threshold: loggy.LevelCritical,\n  }\n  logger, ctx := loggy.New(context.Background(), options)\n\n  // Send a standard message to stdout.\n  logger.Std(ctx, \"hello!\") // 2023-03-29T15:20:55-05:00 OUT main.main ~~~ hello!\n\n  // - Use custom stdout/stderr\n  // - Only show messages that are information, warnings, critical, or standard.\n  stdout := bytes.NewBuffer([]byte{})\n  stderr := bytes.NewBuffer([]byte{})\n  options = loggy.Options{\n    Out: stdout,\n    Err: stderr,\n    Threshold: loggy.LevelInfo,\n  }\n  logger, ctx = loggy.New(context.Background(), options)\n\n  // Send an error message, with the tag \"error\", to the custom stderr buffer.\n  err := errors.New(\"oops\")\n  logger.Critical(ctx, \"something went wrong!\", err.Error())\n\n  // Send a debug message to the custom stdout buffer. This message will be ignored\n  // because of the provided threshold.\n  logger.Debug(ctx, \"get the fly swatter!\")\n\n  fmt.Println(stderr) // 2023-03-29T15:25:27-05:00 CRIT main.main something went wrong! oops\n}\n```\n\n### Testing\n\nRun `go test -v -count=1 ./...` in the project root directory. Use the `-count=1` to force the tests to run un-cached.\n\n_That's all, enjoy!_","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesthoffman%2Floggy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforesthoffman%2Floggy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforesthoffman%2Floggy/lists"}