{"id":23468399,"url":"https://github.com/dikkadev/prettyslog","last_synced_at":"2025-09-01T05:35:59.592Z","repository":{"id":257823033,"uuid":"866704992","full_name":"dikkadev/prettyslog","owner":"dikkadev","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-29T12:24:48.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T00:03:22.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dikkadev.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":"2024-10-02T18:19:58.000Z","updated_at":"2024-10-29T12:24:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"0dfb98d8-131e-49b8-a7d2-e6afc34a6cc9","html_url":"https://github.com/dikkadev/prettyslog","commit_stats":null,"previous_names":["sett17/prettyslog","dikkadev/prettyslog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dikkadev/prettyslog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikkadev%2Fprettyslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikkadev%2Fprettyslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikkadev%2Fprettyslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikkadev%2Fprettyslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dikkadev","download_url":"https://codeload.github.com/dikkadev/prettyslog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikkadev%2Fprettyslog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261973725,"owners_count":23238586,"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":[],"created_at":"2024-12-24T13:52:57.938Z","updated_at":"2025-06-26T00:04:09.811Z","avatar_url":"https://github.com/dikkadev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prettyslog\n\n`prettyslog` is a custom Go `slog` handler that formats log records according to your preferences. It provides a clean, colored text output with configurable options, ensuring your logs are both informative and easy to read.\n\n## Features\n\n- **Customizable Log Format**: Define how your logs look, including timestamp formats and attribute styling.\n- **Color Support**: Enhance readability with color-coded log levels and keys.\n- **Group Handling**: Required group names at the start of each log line, with support for nested groups.\n- **Functional Options**: Easily configure the handler using functional options.\n- **Thread-Safe**: Safe for concurrent use by multiple goroutines.\n\n## Installation\n```bash\ngo get github.com/dikkadev/prettyslog\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"log/slog\"\n    \"github.com/dikkadev/prettyslog\"\n)\n\nfunc main() {\n    // Create a new prettyslog handler with the group \"MyApp\" and default options\n    handler := prettyslog.NewPrettyslogHandler(\"MyApp\")\n\n    // Set the default slog logger to use our custom handler\n    slog.SetDefault(slog.New(handler))\n\n    // Now, use slog as usual\n    slog.Info(\"Application started\", \"version\", \"1.0.0\")\n\n    // Using a logger with additional attributes\n    logger := slog.With(\"request_id\", \"12345\")\n    logger.Info(\"User logged in\", \"username\", \"johndoe\")\n\n    // Using a different group\n    dbLogger := logger.WithGroup(\"db\")\n    dbLogger.Info(\"Query executed\", \"query\", \"SELECT * FROM users\")\n\n    // Including source information\n    handlerWithSource := prettyslog.NewPrettyslogHandler(\"MyApp\",\n        prettyslog.WithSource(true),\n    )\n    slog.SetDefault(slog.New(handlerWithSource))\n    slog.Info(\"This log includes source information\")\n}\n```\n\n## Configuration Options\n\n`prettyslog` uses functional options for configuration:\n\n- `WithTimestamp(enabled bool)`: Enable or disable timestamps. Default is `true`.\n- `WithTimestampFormat(format string)`: Set a custom timestamp format. Default is `\"[15:04:05.000]\"`.\n- `WithSource(enabled bool)`: Include source file and line number. Default is `false`.\n- `WithColors(enabled bool)`: Enable or disable colors. Default is `true`.\n- `WithLevel(level slog.Leveler)`: Set the minimum log level. Default is `slog.LevelInfo`.\n- `WithWriter(w io.Writer)`: Set a custom `io.Writer`. Default is `os.Stderr`.\n\n### Example with Custom Options\n\n```go\nhandler := prettyslog.NewPrettyslogHandler(\"MyApp\",\n    prettyslog.WithSource(true),\n    prettyslog.WithLevel(slog.LevelDebug),\n    prettyslog.WithColors(false),\n    prettyslog.WithTimestampFormat(\"[2006-01-02 15:04:05]\"),\n)\nslog.SetDefault(slog.New(handler))\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdikkadev%2Fprettyslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdikkadev%2Fprettyslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdikkadev%2Fprettyslog/lists"}