{"id":16934227,"url":"https://github.com/codeskyblue/klog","last_synced_at":"2025-12-15T09:11:32.537Z","repository":{"id":10883741,"uuid":"13173598","full_name":"codeskyblue/klog","owner":"codeskyblue","description":"Simple log extention for golang official log,  ^_^ I like simple.","archived":false,"fork":false,"pushed_at":"2014-01-21T07:09:34.000Z","size":256,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-14T20:51:37.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeskyblue.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":"2013-09-28T13:46:20.000Z","updated_at":"2019-04-27T10:55:28.000Z","dependencies_parsed_at":"2022-08-29T20:30:25.632Z","dependency_job_id":null,"html_url":"https://github.com/codeskyblue/klog","commit_stats":null,"previous_names":["shxsun/klog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fklog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fklog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fklog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fklog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeskyblue","download_url":"https://codeload.github.com/codeskyblue/klog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226532949,"owners_count":17647110,"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":[],"created_at":"2024-10-13T20:51:36.453Z","updated_at":"2025-12-15T09:11:32.143Z","avatar_url":"https://github.com/codeskyblue.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# klog\n[![Build Status](https://drone.io/github.com/shxsun/klog/status.png)](https://drone.io/github.com/shxsun/klog/latest)\n\n**library for golang**\n\nFirst thanks to the 3 people who stars of the project **beelog** \nwhich encouraged me to rewrite [beelog](https://github.com/shxsun/beelog), and **klog** comes out.\n\nklog learn from a lot other log system for golang, like [beego](http://github.com/astaxie/beego), [seelog](https://github.com/cihub/seelog), [glog](https://github.com/golang/glog), [qiniu-log](https://github.com/qiniu/log).\n\n# Introdution\nFrom my experience of some project. I think there are only 5 level needed. `Debug Info Warning Error Fatal`\n\nDefault level is Info. Use `SetLevel(level)` to change.\n\nDefault output style is \n```\nprefix 2006/01/02 03:04:05 [INFO] hello world\n```\nUse `SetFlags(klog.Fdevflag)`  will change output to \n```\nprefix 2006/01/02 03:04:05 [INFO] hello.go:7 hello world\n```\n\nColor output is default enabled in console, and auto closed when redirected to a file.\n```\nDEBUG  \"Cyan\",\nINFO   \"Green\",\nWARN   \"Magenta\",\nERROR  \"Yellow\",\nFATAL  \"Red\",\n```\n\n# How to use\n**below this is a simple example**\n\nMore usage please reference \u003chttp://gowalker.org/github.com/shxsun/klog\u003e\n\n`go get github.com/shxsun/klog`\n\n```go\npackage main\nimport \"github.com/shxsun/klog\"\n\nfunc main(){\n\t// Example 1\n\t// use klog.StdLog, klog.DevLog for logging\n\tklog.StdLog.Warnf(\"Hello world\")\n\t// output: 2013/12/01 12:00:00 [Warn] Hello world\n\t// StdLog default level is Warning\n\t\n\tklog.DevLog.Debugf(\"Nice\")\n\t// output: 2013/12/01 12:00:00 main.go:12 [DEBUG] Hello world\n\t\n\t// Example 2\n\tk2 := klog.NewLogger(nil) // Write to stdout\n\t//k := klog.NewLogger(nil, \"option-prefix\") // with prefix\n\t\n\t// Example 3\n\tk3, err := klog.NewFileLogger(\"app.log\")\n\tif err != nil { ...\t}\n\n\tk = klog.DevLog\n\tk.Infof(\"Hi %s.\", \"Susan\")\n\tk.Warn(\"Oh my god, you are alive!\")\n\tk.Error(\"Yes, but I will go to Mars tomorrow. So only one day with you\")\n\tk.Fatal(\"Oh no, donot leave me again... faint\") // Fatal will call os.Exit(1)\n}\n```\n![sample](images/sample.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fklog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeskyblue%2Fklog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fklog/lists"}