{"id":13413341,"url":"https://github.com/nkmr-jp/zl","last_synced_at":"2026-01-04T20:13:40.137Z","repository":{"id":38040042,"uuid":"443433452","full_name":"nkmr-jp/zl","owner":"nkmr-jp","description":"🧑‍💻 High Developer Experience, zap based logger. It offers rich functionality but is easy to configure and allows the user to choose the best output format for their purposes.","archived":false,"fork":false,"pushed_at":"2025-02-19T12:53:38.000Z","size":1196,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T04:30:53.768Z","etag":null,"topics":["developer-experience","golang","logging","pretty","structured-logging","zap"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/nkmr-jp/zl","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/nkmr-jp.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":"2021-12-31T22:19:01.000Z","updated_at":"2025-02-19T12:53:20.000Z","dependencies_parsed_at":"2023-09-22T15:32:03.899Z","dependency_job_id":"0d050adf-bed4-4e81-bd70-c13bdf2b4f00","html_url":"https://github.com/nkmr-jp/zl","commit_stats":null,"previous_names":["nkmr-jp/zap-lightning"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkmr-jp%2Fzl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkmr-jp%2Fzl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkmr-jp%2Fzl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkmr-jp%2Fzl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nkmr-jp","download_url":"https://codeload.github.com/nkmr-jp/zl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635362,"owners_count":20322926,"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":["developer-experience","golang","logging","pretty","structured-logging","zap"],"created_at":"2024-07-30T20:01:38.189Z","updated_at":"2026-01-04T20:13:40.077Z","avatar_url":"https://github.com/nkmr-jp.png","language":"Go","funding_links":[],"categories":["日志记录","Logging"],"sub_categories":["检索及分析资料库","Search and Analytic Databases"],"readme":"# zl :technologist:\n[![Go Reference](https://pkg.go.dev/badge/github.com/nkmr-jp/zl.svg)](https://pkg.go.dev/github.com/nkmr-jp/zl)\n[![test](https://github.com/nkmr-jp/zl/actions/workflows/test.yml/badge.svg)](https://github.com/nkmr-jp/zl/actions/workflows/test.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/nkmr-jp/zl)](https://goreportcard.com/report/github.com/nkmr-jp/zl)\n[![codecov](https://codecov.io/gh/nkmr-jp/zl/branch/main/graph/badge.svg?token=2Z6M2JYT17)](https://codecov.io/gh/nkmr-jp/zl)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\nzl is a logger based on [zap](https://github.com/uber-go/zap). It provides advanced logging features.\n\nzl is a logging package designed with the developer experience in mind.\nYou can choose the most suitable output format according to your purpose, such as emphasizing easy-to-read console output during development in a local environment and outputting structured detailed logs in a production environment.\nIt offers rich functionality but is easy to configure.\n\nThis is useful when developing systems that perform complex processing.\n\n# Features\n## Selectable output format\n### PrettyOutput (Default) :technologist: \n- High Developer Experience.\n- The optimal setting for a development environment.\n- Output colored simple logs to the console.\n- Output detail JSON logs to the logfile.\n- Easy-to-read error reports and stack trace.\n- It can jumps directly to the line of the file that is output to the console log (when using Goland or VSCode).\n\n![image](https://user-images.githubusercontent.com/8490118/185822142-4667200b-8087-49f0-9e41-68ebb1731985.png)\n\nLog messages do not have to be written in upper snake case, \nbut if messages are written in a uniform manner, \nit is easy to extract specific logs using tools such as [Google Cloud Logging](https://cloud.google.com/logging) or the [jq command](https://stedolan.github.io/jq/).\nIt is recommended that log messages be written in a consistent manner.\nBy writing log messages succinctly and placing detailed information in separate fields, \nthe overall clarity of the logs is improved, making it easier to understand the flow of processes.\n\n### ConsoleOutput :zap:\n- High Performance.\n- The optimal setting for a production environment.\n- Output detail JSON logs to the console.\n- Especially suitable for cloud environments such as [Google Cloud Logging](https://cloud.google.com/logging) or [Datadog](https://www.datadoghq.com/).\n- It is fast because it uses only the functions provided by [zap](https://github.com/uber-go/zap#performance) (**not sugared**) and does not perform any extra processing.\n\n### FileOutput\n- The optimal setting for a production environment.\n- It is especially suitable for command line tool or on-premises environments.\n- Support logfile rotation.\n\n### ConsoleAndFileOutput\n- It is a setting for the development environment.\n- Output detail JSON logs to console and logfile.\n- It is recommended to use with [jq command](https://stedolan.github.io/jq/) to avoid drowning in a sea of information.\n- It is recommended to set PrettyOutput instead.\n\n\n# Installation\n\n```sh\ngo get -u github.com/nkmr-jp/zl\n```\n\n# Quick Start\n\ncode: [examples/basic/main.go](examples/basic/main.go)\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"os\"\n\t\"strconv\"\n\n\t\"github.com/nkmr-jp/zl\"\n\t\"go.uber.org/zap\"\n)\n\nfunc main() {\n\t// Set Options\n\tzl.SetLevel(zl.DebugLevel)\n\tzl.SetOmitKeys(zl.HostnameKey)\n\n\t// Initialize\n\tzl.Init()\n\tdefer zl.Sync() // flush log buffer\n\n\t// Write logs\n\tzl.Info(\"USER_INFO\", zap.String(\"user_name\", \"Alice\"), zap.Int(\"user_age\", 20)) // can use zap fields.\n\tzl.Info(\"DISPLAY_TO_CONSOLE\", zl.Console(\"The message you want to display to console\"))\n\tzl.Warn(\"WARN_MESSAGE\")\n\tzl.Debug(\"DEBUG_MESSAGE\")\n\t_, err := os.ReadFile(\"test\")\n\tzl.Err(\"READ_FILE_ERROR\", err)\n\t\n\t// if the same error occurs multiple times in the same location, the error report will show them all together.\n\tfor i := 0; i \u003c 2; i++ {\n\t\t_, err = strconv.Atoi(\"one\")\n\t\tzl.Err(\"A_TO_I_ERROR\", err)\n\t}\n\tfor i := 0; i \u003c 3; i++ {\n\t\tv := \"\"\n\t\terr = json.Unmarshal([]byte(\"test\"), \u0026v)\n\t\tzl.Err(\"JSON_UNMARSHAL_ERROR\", err)\n\t}\n}\n```\n\n**Console output**. \u003cbr\u003e\nThe console displays minimal information. Displays a stack trace when an error occurs.\n![image](https://user-images.githubusercontent.com/8490118/185822142-4667200b-8087-49f0-9e41-68ebb1731985.png)\n\n**File output**. \u003cbr\u003e\nDetailed information is available in the log file. You can also use jq to extract only the information you need.\n```sh\n$ cat log/app.jsonl | jq 'select(.message | startswith(\"USER_\")) | select(.pid==921)'\n```\n```json\n{\n  \"severity\": \"INFO\",\n  \"timestamp\": \"2022-08-22T10:30:39.154575+09:00\",\n  \"caller\": \"basic/main.go:22\",\n  \"function\": \"main.main\",\n  \"message\": \"USER_INFO\",\n  \"version\": \"fc43f68\",\n  \"pid\": 921,\n  \"user_name\": \"Alice\",\n  \"user_age\": 20\n}\n   \n```\n\n# Examples\n- [examples](examples)\n- [example_test.go](example_test.go)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkmr-jp%2Fzl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnkmr-jp%2Fzl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkmr-jp%2Fzl/lists"}