{"id":42666567,"url":"https://github.com/vinbyte/logpaniccollector","last_synced_at":"2026-01-29T10:09:22.072Z","repository":{"id":57608808,"uuid":"234837098","full_name":"vinbyte/logpaniccollector","owner":"vinbyte","description":"Golang package for writing logs or http panic to file","archived":false,"fork":false,"pushed_at":"2020-10-25T15:56:39.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T05:05:07.063Z","etag":null,"topics":["filebeat","golang","golang-library","golang-package","http-panic","logging","middleware","panic","promtail"],"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/vinbyte.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}},"created_at":"2020-01-19T03:54:16.000Z","updated_at":"2024-06-20T05:05:07.064Z","dependencies_parsed_at":"2022-08-30T09:41:27.568Z","dependency_job_id":null,"html_url":"https://github.com/vinbyte/logpaniccollector","commit_stats":null,"previous_names":["rabbitmeow/logpaniccollector"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vinbyte/logpaniccollector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinbyte%2Flogpaniccollector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinbyte%2Flogpaniccollector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinbyte%2Flogpaniccollector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinbyte%2Flogpaniccollector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinbyte","download_url":"https://codeload.github.com/vinbyte/logpaniccollector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinbyte%2Flogpaniccollector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28875450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T09:47:23.353Z","status":"ssl_error","status_checked_at":"2026-01-29T09:47:19.357Z","response_time":59,"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":["filebeat","golang","golang-library","golang-package","http-panic","logging","middleware","panic","promtail"],"created_at":"2026-01-29T10:09:21.364Z","updated_at":"2026-01-29T10:09:22.053Z","avatar_url":"https://github.com/vinbyte.png","language":"Go","readme":"[![GoDoc](https://godoc.org/github.com/vinbyte/logpaniccollector?status.svg)](https://godoc.org/github.com/vinbyte/logpaniccollector)\n\n# What is it ?\n\nThe [Golang](https://golang.org) package for writing log or http panic into file. You can combine this package with [Filebeat](https://www.elastic.co/products/beats/filebeat) or [Promtail](https://github.com/grafana/loki/tree/master/docs/clients/promtail).\n\n## Install\n\n`go get -u github.com/vinbyte/logpaniccollector`\n\nYou can also use vendoring tools like [Govendor](https://github.com/kardianos/govendor), [Dep](https://github.com/golang/dep), or something else.\n\n## Docs\n\n\u003chttps://godoc.org/github.com/vinbyte/logpaniccollector\u003e\n\n## Usage\n\nPlease make your middleware to use the [WritePanic](https://godoc.org/github.com/vinbyte/logpaniccollector#WritePanic) function. Below is the example of Gin middleware\n\nmiddleware/middleware.go :\n```\npackage middleware\n\nimport (\n\t\"fmt\"\n\t\"runtime/debug\"\n\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/vinbyte/logpaniccollector\"\n)\n\n//Middleware ...\ntype Middleware struct{}\n\n// PanicCatcher is use for collecting panic that happened in endpoint\nfunc (w *Middleware) PanicCatcher(lpc *logpaniccollector.LogPanic) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tdefer func() {\n\t\t\tisPanic := lpc.RecoverPanic(c.Request.RequestURI, recover())\n\t\t\tif isPanic {\n\t\t\t\tc.JSON(500, gin.H{\n\t\t\t\t\t\"status\":  500,\n\t\t\t\t\t\"message\": \"Internal server error\",\n\t\t\t\t})\n\t\t\t\tc.Abort()\n\t\t\t}\n\t\t}()\n\t\tc.Next()\n\t}\n}\n```\n\nmain.go\n```\npackage main\n\nimport (\n\t\"[YOUR_MODULE_NAME]/middleware\"\n\t\"github.com/vinbyte/logpaniccollector\"\n\t\"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n    //...\n\tr := gin.Default()\n\tlpc := logpaniccollector.New()\n\tlpc.LogFile = \"log.log\"\n\tlpc.AutoRemoveLog(\"* * * * *\")\n\tvar midd = new(middleware.Middleware)\n\tr.Use(midd.PanicCatcher(lpc))\n    //...\n}\n```\n\n# To Do\n\n- [x] simplify middleware\n- [x] feature cron for auto clean the file\n- [ ] feature enable/disable [the Filebeat multiline support](https://www.elastic.co/guide/en/beats/filebeat/current/multiline-examples.html) (currently is enabled)\n- [ ] feature enable/disable panic log 1 line mode as a follow up from [Promtail issue](https://github.com/grafana/loki/issues/74)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinbyte%2Flogpaniccollector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinbyte%2Flogpaniccollector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinbyte%2Flogpaniccollector/lists"}