{"id":38074627,"url":"https://github.com/derkan/nlog","last_synced_at":"2026-01-16T20:42:52.322Z","repository":{"id":57635036,"uuid":"280649003","full_name":"derkan/nlog","owner":"derkan","description":"Structured Go Logger without external dependencies","archived":false,"fork":false,"pushed_at":"2020-07-18T19:40:23.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T10:08:16.686Z","etag":null,"topics":["console-logger","go","json-logger","logger","logging","rotatelog","syslog"],"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/derkan.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":"2020-07-18T12:10:34.000Z","updated_at":"2020-07-18T19:40:25.000Z","dependencies_parsed_at":"2022-09-13T04:13:07.327Z","dependency_job_id":null,"html_url":"https://github.com/derkan/nlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derkan/nlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fnlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fnlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fnlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fnlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derkan","download_url":"https://codeload.github.com/derkan/nlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fnlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["console-logger","go","json-logger","logger","logging","rotatelog","syslog"],"created_at":"2026-01-16T20:42:51.937Z","updated_at":"2026-01-16T20:42:52.311Z","avatar_url":"https://github.com/derkan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `nlog` logger\n\n`nlog` is a GoLang library for performant logging.\n\n- Easy config, easy API\n- Support multiple formatters\n  - Console formatter(colored)\n  - JSON formatter\n- Different `io.Writer` stream wrappers\n  - Simultaneous logging to multiple writes(via channels) concurrently\n  - Async logging to multiple writes(via channels) concurrently\n    - Writes multiple writers in parellel with buffered channel\n- Includes `syslog` writer(wrapped around standard syslog for correct logging levels)\n- Contextual logging\n  - Allows data to be added to log messages in the form of key:value pairs\n- Structured logging\n  - Logs with levels\n- Minimal memory allocs\n- No dependencies\n- `Hook` support\n- But you can bring your own `json encoder` for serializing objects and define it for a formatter\n- No reflection for high performance\n- Includes `file rotater` log writer with compress support\n- Has a loader from `yaml` formatted config file\n- Sub logger support\n\n## Logging concept\n\n![Logging concept](assets/concept.png)\n\n- Writer is after formatter, so for `nlog` will not build format message for each writer. It will build format only once and use it in all writers assigned to it.\n- You can assign logging level for your formatter. If user log level is too detail, formatter will not format message and will not log it.\n- `nlog` Internally uses buffer pool for low allocation.\n\n## Benchmarks\n\nSome benchmark data\n\n```bash\ngoos: linux\ngoarch: amd64\npkg: github.com/derkan/nlog/log\nBenchmarkInfof-4         2206740               538 ns/op             123 B/op          1 allocs/op\nBenchmarkStr-4           1505314               803 ns/op             216 B/op          1 allocs/op\nBenchmarkWith-4          1453686               798 ns/op             223 B/op          1 allocs/op\n```\n\n## Quick start\n\n```go\npackage main\n\nimport \"github.com/derkan/nlog/log\"\n\nfunc main(){\n    log.Infof(\"test: %d\", 123)\n    log.Info().Str(\"a\", \"string\").Msg(`str \"key\" test`)\n}\n```\n\nAnd you'll get logs on console:\n\n```text\n2020/07/14 22:04:24 INFO test: 123\n2020/07/14 22:04:24 INFO str \"key\" test a=string\n```\n\nIf you want color init logger with your options:\n\n```go\npackage main\n\nimport (\n    \"github.com/derkan/nlog/log\"\n    \"github.com/derkan/nlog/log/formatter/console\"\n)\n\nfunc main() {\n    log.Init(\n        log.WithFormatter(\n            console.NewFormatter(\n                console.WithColor(),\n                console.WithDate(),\n                console.WithTime(),\n            )),\n    )\n    log.Infof(\"test: %d\", 123)\n    log.Debug().Str(\"a\", \"string\").Msg(\"my debug\")\n    log.Warn().Int(\"i\", 4).Msg(\"my warning\")\n    log.Info().Bool(\"b\", true).Strs(\"strslice\", []string{\"a\"}).Msg(\"my bool\")\n    log.Error().Err(nil).With(\"k\", map[string]int{\"x\": 1}).Msg(\"my err with map\")\n}\n```\n\nYou'll get colored output:\n\n![Colored Log](assets/colored.png)\n\n## Installation\n\n```bash\ngo get -u github.com/derkan/nlog\n```\n\n## Formatters\n\nFormatters are used to format log message according to your needs.\n\n### Console Formatter\n\nConsole formatter is used to print plain logs to given `io.WriteCloser`.\n\n| Option       | Default     | Description                       |\n| ------------ | ----------- | --------------------------------- |\n| `WithColor`  | `false`     | When enabled, prints colored logs |\n| `WithWriter` | `os.Stdout` | Where to log messages             |\n\n## TODO\n\n- Documentation\n- Tests\n- Bechmarks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderkan%2Fnlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderkan%2Fnlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderkan%2Fnlog/lists"}