{"id":17016469,"url":"https://github.com/13rac1/spotlog","last_synced_at":"2025-07-26T00:02:44.406Z","repository":{"id":149887845,"uuid":"258604158","full_name":"13rac1/spotlog","owner":"13rac1","description":"A spotlight to locate important logs - A Go logging library extending logrus to increase log relevancy.","archived":false,"fork":false,"pushed_at":"2020-07-28T22:02:14.000Z","size":1171,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T21:12:59.249Z","etag":null,"topics":["golang","logging","logging-library","logrus"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/13rac1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-24T19:25:53.000Z","updated_at":"2023-04-20T05:20:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d9ff356-2562-41a6-a1bc-1154e7b8cd1c","html_url":"https://github.com/13rac1/spotlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/13rac1%2Fspotlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/13rac1%2Fspotlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/13rac1%2Fspotlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/13rac1%2Fspotlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/13rac1","download_url":"https://codeload.github.com/13rac1/spotlog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973810,"owners_count":20541025,"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","logging","logging-library","logrus"],"created_at":"2024-10-14T06:33:24.919Z","updated_at":"2025-03-22T15:17:02.064Z","avatar_url":"https://github.com/13rac1.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spot Log\n\n**A spotlight to locate important logs**\n\nEvery log system provides log levels: set the minimum output level and throw out\nthe rest. The goal is to avoid wasting resources on necessary details. Those\ndetails can be important though. Have you every thought: _\"I wish I had the\ndebug logs for this error!\"_\n\nSpot Log stores logs below the level, then outputs all logs when a log above the\nlevel is received.\n\nSpot Log wraps Logrus implementing 95% the same interface.\n\n## Usage\n\nThe `SpotLogger` instance is stored within the application or request `context`.\nGet it from the `context` and use like any other logger.\n\n```go\nfunc passingCalc(ctx context.Context, w http.ResponseWriter) {\n\t_, logger := spotlog.Get(ctx)\n\tlogger.Debug(\"passed calc\")\n\tw.WriteHeader(http.StatusOK)\n}\n\nfunc failingCalc(ctx context.Context, w http.ResponseWriter) {\n\t_, logger := spotlog.Get(ctx)\n\tlogger.Error(\"failed calc\")\n\tw.WriteHeader(http.StatusInternalServerError)\n}\n\nfunc main() {\n\tpassingHandler := func(w http.ResponseWriter, req *http.Request) {\n\t\tctx, logger := spotlog.Get(req.Context())\n\t\tlogger.Debug(\"request received\")\n\t\tpassingCalc(ctx, w)\n\t\t// Output: nil\n\t}\n\thttp.HandleFunc(\"/pass\", passingHandler)\n\n\tfailingHandler := func(w http.ResponseWriter, req *http.Request) {\n\t\tctx, logger := spotlog.Get(req.Context())\n\t\tlogger.Debug(\"request received\")\n\t\tfailingCalc(ctx, w)\n\t\t// Output:\n\t\t// level=debug msg=\"request received\"\n\t\t// level=error msg=\"failed calc\"\n\t}\n\thttp.HandleFunc(\"/fail\", failingHandler)\n\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n## Ideas\n\n* Logger data fields as global fields. Compare to the existing Entry fields\n  which are attached to an Entry.\n* Print an Entry, but not all stored entries. Probably best at the `Info` level.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F13rac1%2Fspotlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F13rac1%2Fspotlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F13rac1%2Fspotlog/lists"}