{"id":20372621,"url":"https://github.com/txchen/tlog","last_synced_at":"2025-10-11T13:16:51.885Z","repository":{"id":26757057,"uuid":"30214918","full_name":"txchen/tlog","owner":"txchen","description":"a simple log library writes to both file and console","archived":false,"fork":false,"pushed_at":"2015-05-25T16:34:40.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T13:16:49.428Z","etag":null,"topics":[],"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/txchen.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":"2015-02-02T23:41:06.000Z","updated_at":"2015-02-03T06:16:36.000Z","dependencies_parsed_at":"2022-07-14T01:20:29.547Z","dependency_job_id":null,"html_url":"https://github.com/txchen/tlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/txchen/tlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txchen%2Ftlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txchen%2Ftlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txchen%2Ftlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txchen%2Ftlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/txchen","download_url":"https://codeload.github.com/txchen/tlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txchen%2Ftlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007315,"owners_count":26084280,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-15T01:14:05.677Z","updated_at":"2025-10-11T13:16:51.869Z","avatar_url":"https://github.com/txchen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tlog [![wercker status](https://app.wercker.com/status/5cf56d48878565a6da12cafd85e1ac8c/s \"wercker status\")](https://app.wercker.com/project/bykey/5cf56d48878565a6da12cafd85e1ac8c)\nPackage tlog provides simple APIs to write log to console and file simultaneously.\n\nTlog is a wrapper around golang's standard [log](http://golang.org/pkg/log) package.\n\nFeatures:\n* Predefined log levels, from debug to critical.\n* Console and logfile loglevel can be set separately.\n* Console log writes to stderr or stdout according to log level.\n\nLog levels:\n* DEBUG - 1\n* INFO - 2\n* WARN - 3\n* ERROR - 4\n* CRITICAL - 5\n* OFF - 6\n\n### Usage\n\n```go\npackage main\n\nimport (\n  \"log\"\n  \"github.com/txchen/tlog\"\n)\n\nfunc main() {\n  // By default, only log to console\n  tlog.WARN.Println(\"warn\")\n\n  // Default console loglevel is WARN, we can change it\n  tlog.SetConsoleLogLevel(tlog.LevelInfo)\n  tlog.INFO.Println(\"now I can show\")\n\n  // Set logfile to enable file based logging\n  tlog.SetLogFile(\"z.log\")\n  tlog.CRITICAL.Printf(\"2 + 2 = %d\", 4)\n\n  // By default, logfile loglevel is INFO, let's change it\n  tlog.SetLogfileLogLevel(tlog.LevelDebug)\n  tlog.Debug.Println(\"you can only see me in file\")\n\n  // By default, tlog use Ldate | Ltime flag, you can tune it\n  tlog.SetLogFlags(log.Ldate | log.Ltime | log.Lshortfile)\n  // Now you can see different logging style\n  tlog.ERROR.Println(\"different style\")\n\n  // And you can turn off the flag\n  tlog.SetLogFlags(0)\n  // Now the output will be \"WARN: clean\"\n  tlog.WARN.Println(\"clean\")\n\n  // To turn off logging, set the level to off\n  tlog.SetLogfileLogLevel(tlog.LevelOff)\n  tlog.SetConsoleLogLevel(tlog.LevelOff)\n  tlog.CRITICAL.Println(\"no one can see me\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxchen%2Ftlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftxchen%2Ftlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxchen%2Ftlog/lists"}