{"id":13366589,"url":"https://github.com/kpanGo/glg","last_synced_at":"2025-03-12T18:31:08.254Z","repository":{"id":43612763,"uuid":"95006858","full_name":"kpango/glg","owner":"kpango","description":"Simple and blazing fast lockfree logging library for golang","archived":false,"fork":false,"pushed_at":"2024-09-17T17:14:28.000Z","size":21457,"stargazers_count":190,"open_issues_count":3,"forks_count":17,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-10-25T05:22:55.017Z","etag":null,"topics":["fast","glg","golang","kpango","log","logger","simple"],"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/kpango.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":"2017-06-21T13:26:16.000Z","updated_at":"2024-09-17T17:14:32.000Z","dependencies_parsed_at":"2024-06-18T13:55:12.760Z","dependency_job_id":"7189d305-8afe-485e-b730-b397460dfad6","html_url":"https://github.com/kpango/glg","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpango%2Fglg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpango%2Fglg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpango%2Fglg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpango%2Fglg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpango","download_url":"https://codeload.github.com/kpango/glg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243271214,"owners_count":20264412,"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":["fast","glg","golang","kpango","log","logger","simple"],"created_at":"2024-07-30T00:01:27.728Z","updated_at":"2025-03-12T18:31:07.925Z","avatar_url":"https://github.com/kpango.png","language":"Go","readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./images/logo.png\" width=\"50%\"\u003e\n\u003c/div\u003e\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n[![release](https://img.shields.io/github/release/kpango/glg.svg?style=flat-square)](https://github.com/kpango/glg/releases/latest)\n[![CircleCI](https://circleci.com/gh/kpango/glg.svg)](https://circleci.com/gh/kpango/glg)\n[![codecov](https://codecov.io/gh/kpango/glg/branch/main/graph/badge.svg?token=2CzooNJtUu\u0026style=flat-square)](https://codecov.io/gh/kpango/glg)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a6e544eee7bc49e08a000bb10ba3deed)](https://www.codacy.com/app/i.can.feel.gravity/glg?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=kpango/glg\u0026amp;utm_campaign=Badge_Grade)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kpango/glg)](https://goreportcard.com/report/github.com/kpango/glg)\n[![GolangCI](https://golangci.com/badges/github.com/kpango/glg.svg?style=flat-square)](https://golangci.com/r/github.com/kpango/glg)\n[![Go Walker](http://gowalker.org/api/v1/badge)](https://gowalker.org/github.com/kpango/glg)\n[![GoDoc](http://godoc.org/github.com/kpango/glg?status.svg)](http://godoc.org/github.com/kpango/glg)\n[![DepShield Badge](https://depshield.sonatype.org/badges/kpango/glg/depshield.svg)](https://depshield.github.io)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkpango%2Fglg.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkpango%2Fglg?ref=badge_shield)\n\n\nglg is simple golang logging library\n\n## Requirement\nGo 1.16\n\n## Installation\n```shell\ngo get github.com/kpango/glg\n```\n\n## Example\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/kpango/glg\"\n)\n\n// NetWorkLogger sample network logger\ntype NetWorkLogger struct{}\n\nfunc (n NetWorkLogger) Write(b []byte) (int, error) {\n\t// http.Post(\"localhost:8080/log\", \"\", bytes.NewReader(b))\n\thttp.Get(\"http://127.0.0.1:8080/log\")\n\tglg.Success(\"Requested\")\n\tglg.Infof(\"RawString is %s\", glg.RawString(b))\n\treturn 1, nil\n}\n\nfunc main() {\n\n\t// var errWriter io.Writer\n\t// var customWriter io.Writer\n\tinfolog := glg.FileWriter(\"/tmp/info.log\", 0666)\n\n\tcustomTag := \"FINE\"\n\tcustomErrTag := \"CRIT\"\n\n\terrlog := glg.FileWriter(\"/tmp/error.log\", 0666)\n\tdefer infolog.Close()\n\tdefer errlog.Close()\n\n\tglg.Get().\n\t\tSetMode(glg.BOTH). // default is STD\n\t\t// DisableColor().\n\t\t// SetMode(glg.NONE).\n\t\t// SetMode(glg.WRITER).\n\t\t// SetMode(glg.BOTH).\n\t\t// InitWriter().\n\t\t// AddWriter(customWriter).\n\t\t// SetWriter(customWriter).\n\t\t// AddLevelWriter(glg.LOG, customWriter).\n\t\t// AddLevelWriter(glg.INFO, customWriter).\n\t\t// AddLevelWriter(glg.WARN, customWriter).\n\t\t// AddLevelWriter(glg.ERR, customWriter).\n\t\t// SetLevelWriter(glg.LOG, customWriter).\n\t\t// SetLevelWriter(glg.INFO, customWriter).\n\t\t// SetLevelWriter(glg.WARN, customWriter).\n\t\t// SetLevelWriter(glg.ERR, customWriter).\n\t\t// EnableJSON().\n\t\tSetLineTraceMode(glg.TraceLineNone).\n\t\tAddLevelWriter(glg.INFO, infolog). // add info log file destination\n\t\tAddLevelWriter(glg.ERR, errlog).   // add error log file destination\n\t\tAddLevelWriter(glg.WARN, rotate)   // add error log file destination\n\n\tglg.Info(\"info\")\n\tglg.Infof(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Log(\"log\")\n\tglg.Logf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Debug(\"debug\")\n\tglg.Debugf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Trace(\"Trace\")\n\tglg.Tracef(\"%s : %s\", \"tracef\", \"formatted\")\n\tglg.Warn(\"warn\")\n\tglg.Warnf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Error(\"error\")\n\tglg.Errorf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Success(\"ok\")\n\tglg.Successf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Fail(\"fail\")\n\tglg.Failf(\"%s : %s\", \"info\", \"formatted\")\n\tglg.Print(\"Print\")\n\tglg.Println(\"Println\")\n\tglg.Printf(\"%s : %s\", \"printf\", \"formatted\")\n\n\t// set global log level to ERR level\n\tglg.Info(\"before setting level to ERR this message will show\")\n\tglg.Get().SetLevel(glg.ERR)\n\tglg.Info(\"after setting level to ERR this message will not show\")\n\tglg.Error(\"this log is ERR level this will show\")\n\tglg.Get().SetLevel(glg.DEBG)\n\tglg.Info(\"log level is now DEBG, this INFO level log will show\")\n\n\tglg.Get().\n\t\tAddStdLevel(customTag, glg.STD, false).                    // user custom log level\n\t\tAddErrLevel(customErrTag, glg.STD, true).                  // user custom error log level\n\t\tSetLevelColor(glg.TagStringToLevel(customTag), glg.Cyan).  // set color output to user custom level\n\t\tSetLevelColor(glg.TagStringToLevel(customErrTag), glg.Red) // set color output to user custom level\n\tglg.CustomLog(customTag, \"custom logging\")\n\tglg.CustomLog(customErrTag, \"custom error logging\")\n\n\t// glg.Info(\"kpango's glg supports disable timestamp for logging\")\n\tglg.Get().DisableTimestamp()\n\tglg.Info(\"timestamp disabled\")\n\tglg.Warn(\"timestamp disabled\")\n\tglg.Log(\"timestamp disabled\")\n\tglg.Get().EnableTimestamp()\n\tglg.Info(\"timestamp enabled\")\n\tglg.Warn(\"timestamp enabled\")\n\tglg.Log(\"timestamp enabled\")\n\n\tglg.Info(\"kpango's glg support line trace logging\")\n\tglg.Error(\"error log shows short line trace by default\")\n\tglg.Info(\"error log shows none trace by default\")\n\tglg.Get().SetLineTraceMode(glg.TraceLineShort)\n\tglg.Error(\"after configure TraceLineShort, error log shows short line trace\")\n\tglg.Info(\"after configure TraceLineShort, info log shows short line trace\")\n\tglg.Get().DisableTimestamp()\n\tglg.Error(\"after configure TraceLineShort and DisableTimestamp, error log shows short line trace without timestamp\")\n\tglg.Info(\"after configure TraceLineShort and DisableTimestamp, info log shows short line trace without timestamp\")\n\tglg.Get().EnableTimestamp()\n\tglg.Get().SetLineTraceMode(glg.TraceLineLong)\n\tglg.Error(\"after configure TraceLineLong, error log shows long line trace\")\n\tglg.Info(\"after configure TraceLineLong, info log shows long line trace\")\n\tglg.Get().DisableTimestamp()\n\tglg.Error(\"after configure TraceLineLong and DisableTimestamp, error log shows long line trace without timestamp\")\n\tglg.Info(\"after configure TraceLineLong and DisableTimestamp, info log shows long line trace without timestamp\")\n\tglg.Get().EnableTimestamp()\n\tglg.Get().SetLineTraceMode(glg.TraceLineNone)\n\tglg.Error(\"after configure TraceLineNone, error log without line trace\")\n\tglg.Info(\"after configure TraceLineNone, info log without line trace\")\n\tglg.Get().SetLevelLineTraceMode(glg.INFO, glg.TraceLineLong)\n\tglg.Info(\"after configure Level trace INFO=TraceLineLong, only info log shows long line trace\")\n\tglg.Error(\"after configure Level trace INFO=TraceLineLong, error log without long line trace\")\n\tglg.Get().SetLevelLineTraceMode(glg.ERR, glg.TraceLineShort)\n\tglg.Info(\"after configure Level trace ERR=TraceLineShort, info log still shows long line trace\")\n\tglg.Error(\"after configure Level trace ERR=TraceLineShort, error log now shows short line trace\")\n\tglg.Get().SetLineTraceMode(glg.TraceLineNone)\n\n\tglg.Info(\"kpango's glg support json logging\")\n\tglg.Get().EnableJSON()\n\terr := glg.Warn(\"kpango's glg\", \"support\", \"json\", \"logging\")\n\tif err != nil {\n\t\tglg.Get().DisableJSON()\n\t\tglg.Error(err)\n\t\tglg.Get().EnableJSON()\n\t}\n\terr = glg.Info(\"hello\", struct {\n\t\tName   string\n\t\tAge    int\n\t\tGender string\n\t}{\n\t\tName:   \"kpango\",\n\t\tAge:    28,\n\t\tGender: \"male\",\n\t}, 2020)\n\tif err != nil {\n\t\tglg.Get().DisableJSON()\n\t\tglg.Error(err)\n\t\tglg.Get().EnableJSON()\n\t}\tglg.CustomLog(customTag, \"custom logging\")\n\n\tglg.CustomLog(customErrTag, \"custom error logging\")\n\n\tglg.Get().AddLevelWriter(glg.DEBG, NetWorkLogger{}) // add info log file destination\n\n\thttp.Handle(\"/glg\", glg.HTTPLoggerFunc(\"glg sample\", func(w http.ResponseWriter, r *http.Request) {\n\t\tglg.New().\n\t\tAddLevelWriter(glg.Info, NetWorkLogger{}).\n\t\tAddLevelWriter(glg.Info, w).\n\t\tInfo(\"glg HTTP server logger sample\")\n\t}))\n\n\thttp.ListenAndServe(\"port\", nil)\n\n\t// fatal logging\n\tglg.Fatalln(\"fatal\")\n}\n```\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./images/sample.png\" width=\"100%\"\u003e\n\u003c/div\u003e\n\n## Benchmarks\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./images/bench.png\" width=\"100%\"\u003e\n\u003c/div\u003e\n\n## Contribution\n1. Fork it ( https://github.com/kpango/glg/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create new Pull Request\n\n## Author\n[kpango](https://github.com/kpango)\n\n## LICENSE\nglg released under MIT license, refer [LICENSE](https://github.com/kpango/glg/blob/main/LICENSE) file.  \n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkpango%2Fglg.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkpango%2Fglg?ref=badge_large)\n","funding_links":[],"categories":["日誌","日志"],"sub_categories":["高級控制台界面","高级控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FkpanGo%2Fglg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FkpanGo%2Fglg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FkpanGo%2Fglg/lists"}