{"id":16874532,"url":"https://github.com/joway/loki","last_synced_at":"2025-10-19T21:32:55.714Z","repository":{"id":52420206,"uuid":"175546089","full_name":"joway/loki","owner":"joway","description":"Minimalist logger for Golang","archived":false,"fork":false,"pushed_at":"2021-04-29T19:31:47.000Z","size":154,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T12:05:36.122Z","etag":null,"topics":["colorful","debug","golang","log","logger","loki","minimalist","nodejs"],"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/joway.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-03-14T04:06:41.000Z","updated_at":"2020-09-08T02:35:44.000Z","dependencies_parsed_at":"2022-09-11T16:01:22.151Z","dependency_job_id":null,"html_url":"https://github.com/joway/loki","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/joway/loki","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Floki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Floki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Floki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Floki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joway","download_url":"https://codeload.github.com/joway/loki/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Floki/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268269069,"owners_count":24223182,"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-08-01T02:00:08.611Z","response_time":67,"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":["colorful","debug","golang","log","logger","loki","minimalist","nodejs"],"created_at":"2024-10-13T15:33:11.098Z","updated_at":"2025-10-19T21:32:55.649Z","avatar_url":"https://github.com/joway.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loki\n\n![GitHub release](https://img.shields.io/github/tag/joway/loki.svg?label=release)\n[![Go Report Card](https://goreportcard.com/badge/github.com/joway/loki)](https://goreportcard.com/report/github.com/joway/loki)\n[![codecov](https://codecov.io/gh/joway/loki/branch/master/graph/badge.svg)](https://codecov.io/gh/joway/loki)\n[![CircleCI](https://circleci.com/gh/joway/loki.svg?style=shield)](https://circleci.com/gh/joway/loki)\n\nInspired by a popular NodeJS logger library: [debug](https://www.npmjs.com/package/debug).\n\n## Feature\n\n- Out of the box\n- Colorful console output\n- Enable logger by environment easily\n\n![](./demo.png)\n\n## Difference with other logger library\n\nSometimes, it's not enough to split loggers by different log level. \n\nWith Loki, you can inject more detailed logs in your code, and enable them by environment variable whenever you want, which makes debug more conveniently.\n\n## Install\n\n```bash\ngo get github.com/joway/loki@latest\n```\n\n## API\n\n[![Go Doc](https://godoc.org/github.com/joway/loki?status.svg)](https://godoc.org/github.com/joway/loki)\n\n## Usage\n\n### Use root logger\n\n```go\n// default level is INFO\nloki.SetLevel(loki.DEBUG)\n\nloki.Info(\"x: %s\", \"hi\")\nloki.Debug(\"x: %s\", \"hi\")\nloki.Error(\"x: %s\", \"hi\")\n```\n\n### Create your logger\n\n```go\nlogger := loki.New(\"app:moduleName\")\nlogger.Info(\"x: %s\", \"hi\")\nlogger.Debug(\"x: %s\", \"hi\")\nlogger.Error(\"x: %s\", \"hi\")\n```\n\nTo enable this logger, add env `LOKI_ENV=app:moduleName` in your startup command, like: `LOKI_ENV=app:moduleName ./main`.\n\nYou can also use `LOKI_ENV=app:a,app:b,model:a` to enable multiple loggers.\n\n`LOKI_ENV=*` can enable all loggers.\n\n### Use file handler\n\n```go\n// \"02 Jan 06 15:04 MST\"\nl := loki.New(\"app:xxx\")\nfp, err := os.OpenFile(\"test.log\", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)\ndefer fp.Close()\nflushIntervalMs := 1000\nl.SetHandler(loki.NewFileHandler(fp, flushIntervalMs))\n\nl.Info(\"x: %s\", \"hi\")\n```\n\n### Change time format\n\n```go\n// \"02 Jan 06 15:04 MST\"\nloki.SetTimeFormatter(time.RFC822)\n\n// disable time output\nloki.SetTimeFormatter(\"\")\n```\n\n### Use your custom logger formatter\n\n```go\ntype ErrFormatter struct {\n\tloki.Formatter\n}\n\nfunc (f ErrFormatter) format(a ...interface{}) string {\n\terr := a[0].(error)\n\treturn fmt.Sprintf(\"Error %v\", err)\n}\n\nlogger := loki.New(\"app:xxx\")\nf := ErrFormatter{}\nlogger.SetFormatter(f)\nlogger.Debug(errors.New(\"test error\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Floki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoway%2Floki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Floki/lists"}