{"id":31286961,"url":"https://github.com/nentgroup/slog-prettylogger","last_synced_at":"2025-09-24T10:59:24.021Z","repository":{"id":315636189,"uuid":"1058246709","full_name":"nentgroup/slog-prettylogger","owner":"nentgroup","description":"A pretty logger handler for slog","archived":false,"fork":false,"pushed_at":"2025-09-16T22:45:40.000Z","size":317,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-19T20:06:03.893Z","etag":null,"topics":["go","golang","logging","slog","slog-handler"],"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/nentgroup.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-16T20:34:00.000Z","updated_at":"2025-09-16T22:55:47.000Z","dependencies_parsed_at":"2025-09-19T20:06:09.325Z","dependency_job_id":"035c9af8-82eb-468f-988e-620b864e3942","html_url":"https://github.com/nentgroup/slog-prettylogger","commit_stats":null,"previous_names":["nentgroup/slog-prettylogger"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nentgroup/slog-prettylogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nentgroup%2Fslog-prettylogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nentgroup%2Fslog-prettylogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nentgroup%2Fslog-prettylogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nentgroup%2Fslog-prettylogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nentgroup","download_url":"https://codeload.github.com/nentgroup/slog-prettylogger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nentgroup%2Fslog-prettylogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276229766,"owners_count":25606954,"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-09-21T02:00:07.055Z","response_time":72,"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":["go","golang","logging","slog","slog-handler"],"created_at":"2025-09-24T10:59:22.999Z","updated_at":"2025-09-24T10:59:24.011Z","avatar_url":"https://github.com/nentgroup.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./.github/assets/gopher.png\" align=\"right\" height=\"96\" width=\"96\"/\u003e\n\n# Slog Pretty Logger\n\n[![Tests](https://github.com/nentgroup/slog-prettylogger/actions/workflows/test.yml/badge.svg)](https://github.com/nentgroup/slog-prettylogger/actions/workflows/test.yml)\n[![Go Coverage](https://github.com/nentgroup/slog-prettylogger/wiki/coverage.svg)](https://raw.githack.com/wiki/nentgroup/slog-prettylogger/coverage.html)\n[![Go Reference](https://pkg.go.dev/badge/github.com/nentgroup/slog-prettylogger.svg)](https://pkg.go.dev/github.com/nentgroup/slog-prettylogger)\n[![Go Report Card](https://goreportcard.com/badge/github.com/nentgroup/slog-prettylogger)](https://goreportcard.com/report/github.com/nentgroup/slog-prettylogger)\n[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/zerolog/master/LICENSE)\n\nA colorful, readable logging handler for Go's standard `slog` package. Makes logs easier to read during development with color-coded levels and clean formatting. Inspired by zerolog's console output.\n\n## Features\n\n- 🎨 **Color-coded levels**: DEBUG, INFO, WARN, ERROR\n- 🔍 **Bold messages**: Highlights log messages and errors\n- 🧩 **Field formatting**: Formats fields based on type\n- ⏱ **Custom time**: Override the default `time.Kitchen` format\n- 🚫 **No-color mode**: Disable ANSI colors\n- 🖌️ **Custom colors**: Set your own colors per log level\n\n\n## Installation\n\n```bash\ngo get github.com/nentgroup/slog-prettylogger\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"log/slog\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/nentgroup/slog-prettylogger\"\n)\n\nfunc main() {\n\t// Create a new pretty logger\n\tlogger := slog.New(prettylogger.NewHandler(os.Stdout, prettylogger.HandlerOptions{\n\t\tSlogOpts: slog.HandlerOptions{\n\t\t\tAddSource: true, // Include caller information\n\t\t\tLevel:     slog.LevelDebug,\n\t\t},\n\t\tTimeFormat: time.TimeOnly, // Customize time format, default is time.Kitchen\n\t}))\n\n\t// Set as default logger\n\tslog.SetDefault(logger)\n\n\t// Basic logging\n\tslog.Info(\"application started\", \"version\", \"1.0.0\")\n\tslog.Debug(\"debug information\", \"cache_hits\", 42)\n\tslog.Warn(\"resource usage high\", \"cpu\", 85.5, \"memory\", \"3.2GB\")\n\tslog.Error(\"failed to connect to database\",\n\t\t\"error\", \"connection refused\",\n\t\t\"retry_count\", 3,\n\t\t\"db_host\", \"localhost:5432\")\n\n\t// With structured data\n\tlogger.Info(\"user logged in\",\n\t\t\"user_id\", 123,\n\t\t\"metadata\", map[string]interface{}{\n\t\t\t\"browser\":  \"Chrome\",\n\t\t\t\"version\":  \"98.0.4758.102\",\n\t\t\t\"platform\": \"macOS\",\n\t\t})\n}\n```\n\n## Output Example\n\nWhen using pretty logger, your console output will look similar to:\n\n![Pretty Logger Output Example](./.github/assets/example.png)\n\n## Configuration Options\n\nUse the `HandlerOptions` struct to customize the logger:\n\n```go\ntype HandlerOptions struct {\n    SlogOpts    slog.HandlerOptions        // Standard slog handler options (level, AddSource, etc.)\n    TimeFormat  string                     // Optional: custom time format (default is time.Kitchen)\n    NoColor     bool                       // Optional: disable ANSI colors\n    LevelColors map[slog.Level]string      // Optional: override colors per log level (DEBUG, INFO, WARN, ERROR)\n}\n```\n\n### Example with custom colors\n\n```go\nlogger := slog.New(prettylogger.NewHandler(os.Stdout, prettylogger.HandlerOptions{\n\tSlogOpts: slog.HandlerOptions{\n\t\tAddSource: true,\n\t\tLevel:     slog.LevelDebug,\n\t},\n\tTimeFormat:  time.RFC3339,\n\tLevelColors: map[slog.Level]string{slog.LevelError: prettylogger.BoldRed}, // or use any ANSI color code\n}))\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Acknowledgements\n\nDeveloped and maintained by [Viaplay Group](https://github.com/nentgroup).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnentgroup%2Fslog-prettylogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnentgroup%2Fslog-prettylogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnentgroup%2Fslog-prettylogger/lists"}