{"id":13413285,"url":"https://github.com/lajosbencz/glo","last_synced_at":"2025-08-18T10:32:25.024Z","repository":{"id":57487735,"uuid":"166598763","full_name":"lajosbencz/glo","owner":"lajosbencz","description":"Logging library for Golang","archived":false,"fork":false,"pushed_at":"2019-01-23T11:35:10.000Z","size":38,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:52:12.801Z","etag":null,"topics":["golang","log"],"latest_commit_sha":null,"homepage":null,"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/lajosbencz.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}},"created_at":"2019-01-19T22:10:42.000Z","updated_at":"2022-09-26T23:22:25.000Z","dependencies_parsed_at":"2022-08-29T11:21:35.609Z","dependency_job_id":null,"html_url":"https://github.com/lajosbencz/glo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lajosbencz%2Fglo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lajosbencz%2Fglo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lajosbencz%2Fglo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lajosbencz%2Fglo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lajosbencz","download_url":"https://codeload.github.com/lajosbencz/glo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230225630,"owners_count":18193015,"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","log"],"created_at":"2024-07-30T20:01:36.833Z","updated_at":"2024-12-18T06:17:01.885Z","avatar_url":"https://github.com/lajosbencz.png","language":"Go","funding_links":[],"categories":["Logging","日志记录","Logging 日志库","Relational Databases"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","SQL 查询语句构建库","Advanced Console UIs"],"readme":"[![GoDoc](https://godoc.org/github.com/lajosbencz/glo?status.svg)](https://godoc.org/github.com/lajosbencz/glo)\n[![Go Report Card](https://goreportcard.com/badge/github.com/lajosbencz/glo)](https://goreportcard.com/report/github.com/lajosbencz/glo)\n[![codecov](https://codecov.io/gh/lajosbencz/glo/branch/master/graph/badge.svg)](https://codecov.io/gh/lajosbencz/glo)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/696a39293abd4f42b3f749c8b022a039)](https://app.codacy.com/app/lajosbencz/glo)\n[![Build Status](https://travis-ci.com/lajosbencz/glo.svg?branch=master)](https://travis-ci.com/lajosbencz/glo.svg?branch=master)\n\n# GLO\n\n## Logging library for Golang\n\nInspired by Monolog for PHP, severity levels are identical\n\n### Install\n\n```bash\ngo get github.com/lajosbencz/glo\n```\n\n### Severity levels\n\n```bash\nDebug     = 100\nInfo      = 200\nNotice    = 250\nWarning   = 300\nError     = 400\nCritical  = 500\nAlert     = 550\nEmergency = 600\n```\n\n### Simple example\n\n```go\npackage main\n\nimport \"github.com/lajosbencz/glo\"\n\nfunc main() {\n\t// Info - Warning will go to os.Stdout\n\t// Error - Emergency will go to os.Stderr\n\tlog := glo.NewStdFacility()\n\n\t// goes to os.Stdout\n\tlog.Debug(\"Detailed debug line: %#v\", map[string]string{\"x\": \"foo\", \"y\": \"bar\"})\n\n\t// goes to os.Stderr\n\tlog.Error(\"Oooof!\")\n}\n```\n\nOutput:\n\n```bash\n2019-01-22T15:16:08+01:00 [DEBUG] Detailed debug line [map[x:foo y:bar]]\n2019-01-22T15:16:08+01:00 [ERROR] Oooof! []\n```\n\n### Customized example\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/lajosbencz/glo\"\n)\n\nfunc main() {\n\tlog := glo.NewFacility()\n\n\t// write everything to a buffer\n\tbfr := bytes.NewBufferString(\"\")\n\thandlerBfr := glo.NewHandler(bfr)\n\tlog.PushHandler(handlerBfr)\n\n\t// write only errors and above using a short format\n\thandlerStd := glo.NewHandler(os.Stdout)\n\tformatter := glo.NewFormatter(\"{L}: {M}\")\n\tfilter := glo.NewFilterLevel(glo.Error)\n\thandlerStd.SetFormatter(formatter)\n\thandlerStd.PushFilter(filter)\n\tlog.PushHandler(handlerStd)\n\n\tfmt.Println(\"Log output:\")\n\tfmt.Println(strings.Repeat(\"=\", 70))\n\tlog.Info(\"Only written to the buffer\")\n\tlog.Alert(\"Written to both buffer and stdout\")\n\n\tfmt.Println(\"\")\n\tfmt.Println(\"Buffer contents:\")\n\tfmt.Println(strings.Repeat(\"=\", 70))\n\tfmt.Println(bfr.String())\n}\n```\n\nOutput:\n\n```bash\nLog output:\n======================================================================\nALERT: Written to both buffer and stdout []\n\nBuffer contents:\n======================================================================\n2019-01-22T15:14:16+01:00 [INFO] Only written to the buffer []\n2019-01-22T15:14:16+01:00 [ALERT] Written to both buffer and stdout []\n```\n\n### Custom filter\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\t\"regexp\"\n\n\t\"github.com/lajosbencz/glo\"\n)\n\nfunc main() {\n\thandler := glo.NewHandler(os.Stdout)\n\tfilterEmptyLines := \u0026filterRgx{regexp.MustCompile(`^.+$`)}\n\thandler.PushFilter(filterEmptyLines)\n\n\tlog := glo.NewFacility()\n\tlog.PushHandler(handler)\n\n\tlog.Debug(\"\", \"format is empty, should be ignored\")\n\tlog.Debug(\"only this should appear at the output\")\n}\n\ntype filterRgx struct {\n\trgx *regexp.Regexp\n}\n\nfunc (f *filterRgx) Check(level glo.Level, line string, params ...interface{}) bool {\n\treturn f.rgx.MatchString(line)\n}\n```\n\nOutput:\n\n```bash\n2019-01-22T15:30:23+01:00 [DEBUG] only this should appear at the output\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flajosbencz%2Fglo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flajosbencz%2Fglo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flajosbencz%2Fglo/lists"}