{"id":24122188,"url":"https://github.com/tlinden/yadu","last_synced_at":"2025-12-15T11:52:55.093Z","repository":{"id":217883899,"uuid":"745029876","full_name":"TLINDEN/yadu","owner":"TLINDEN","description":"A human readable slog.Handler using YAML to show attrs","archived":false,"fork":false,"pushed_at":"2024-02-14T12:14:43.000Z","size":36,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-02T11:57:58.454Z","etag":null,"topics":["color","golang","log","log-level","logger","slog","slog-handler","structured-logging","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TLINDEN.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-01-18T13:59:58.000Z","updated_at":"2024-02-29T11:23:57.000Z","dependencies_parsed_at":"2024-06-21T19:04:51.809Z","dependency_job_id":"4a65836d-bfdf-4381-8d0d-c76c7ffa715d","html_url":"https://github.com/TLINDEN/yadu","commit_stats":null,"previous_names":["tlinden/yamldumphandler"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/TLINDEN/yadu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLINDEN%2Fyadu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLINDEN%2Fyadu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLINDEN%2Fyadu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLINDEN%2Fyadu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TLINDEN","download_url":"https://codeload.github.com/TLINDEN/yadu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLINDEN%2Fyadu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27750511,"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-12-15T02:00:09.782Z","response_time":96,"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":["color","golang","log","log-level","logger","slog","slog-handler","structured-logging","yaml"],"created_at":"2025-01-11T11:38:51.849Z","updated_at":"2025-12-15T11:52:55.086Z","avatar_url":"https://github.com/TLINDEN.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![status-badge](https://ci.codeberg.org/api/badges/15686/status.svg)](https://ci.codeberg.org/repos/15686)\n[![Go Report Card](https://goreportcard.com/badge/github.com/tlinden/yadu)](https://goreportcard.com/report/github.com/tlinden/yadu)\n[![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://codeberg.org/scip/yadu/raw/branch/main/LICENSE)\n[![GoDoc](https://godoc.org/github.com/tlinden/yadu?status.svg)](https://godoc.org/github.com/tlinden/yadu)\n\n# yadu - a human readable yaml based slog.Handler\n\n## Introduction\n\nPackage yadu provides a handler for the log/slog logging framework.\n\nIt generates a  mixture of text lines containing  the timestamp and\nlog message and a YAML dump of the provided attibutes.\n\n## Log format\n\nThe log format generated by yadu looks like this:\n\n```\n2023-04-02T10:50.09 EDT LEVEL Message text\n    foo: value\n    bar: 12345\n```\n\n## Example\n\n```go\nlogger := slog.New(yadu.NewHandler(os.Stdout, nil))\n\ntype body string\n\ntype Ammo struct {\n        Forweapon string\n        Impact    int\n        Cost      int\n        Range     int\n}\n\ntype Enemy struct {\n    Alive  bool\n    Health int\n    Name   string\n    Body   body `yaml:\"-\"` // not printed\n    Ammo   []Ammo\n}\n\ne := \u0026Enemy{Alive: true, Health: 10, Name: \"Bodo\", Body: \"body\\nbody\\n\",\n    Ammo: []Ammo{{Forweapon: \"Railgun\", Range: 400, Impact: 100, Cost: 100000}},\n}\n\nslog.Info(\"info\", \"enemy\", e, \"spawn\", 199)\n```\n\nOutput:\n\n```sh\n2024-01-18T02:57.41 CET INFO: info \n    enemy:\n        alive: true\n        health: 10\n        name: Bodo\n        ammo:\n            - forweapon: Railgun\n              impact: 100\n              cost: 100000\n              range: 400\n    spawn: 199\n```\n\nSee `example/example.go` for usage.\n\n## Installation\n\nExecute this to add the module to your project:\n```sh\ngo get github.com/tlinden/yadu/v2\n```\n\n## Configuration\n\nYou can tweak the behavior of the handler as any other handler by using the Options struct:\n\n```go\nfunc removeTime(_ []string, a slog.Attr) slog.Attr {\n        if a.Key == slog.TimeKey {\n                return slog.Attr{}\n        }\n        return a\n}\n\nopts := \u0026yadu.Options{\n           Level: slog.LevelDebug,\n           ReplaceAttr: removeTime,\n        }\n```\n\nPass this object to `yadu.NewHandler()`.\n\nBecause you can pass whole structs  to the logger which will be dumped\nusing YAML, there's also a way to exclude fields from being printed:\n\n```go\ntype User struct {\n  Id int\n  User string\n  Pass string `yaml:\"-\"`\n}\n```\n\nIf you're already using YAML tags for other purposes you can also just\nadd a  `LogValue()` method  to your  struct, which  will be  called by\nslog. Refer to the slog documentation how to use it.\n\nYou can also modify the time format using `yadu.Options.TimeFormat`.\n\n## Acknowledgements\n\nI  wrote  most  of  the  code  with  the  help  of  the  [humane  slog\nhandler][humane]. Also helpfull was the  [guide to writing `slog` handlers][guide].\n\n+ [humane slog handler][humane]\n+ [A Guide to Writing `slog` Handlers][guide]\n+ [A Comprehensive Guide to Structured Logging in Go][betterstack]\n\n[humane]: https://github.com/telemachus/humane/tree/main\n[guide]: https://github.com/golang/example/tree/master/slog-handler-guide\n[betterstack]: https://betterstack.com/community/guides/logging/logging-in-go/\n\n## LICENSE\n\nThis  module  is  published  under  the  terms  of  the  BSD  3-Clause\nLicense. Please read the file LICENSE for details.\n\n## Author\n\nThomas von Dein `\u003cgit |AT| daemon.de\u003e`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlinden%2Fyadu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftlinden%2Fyadu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlinden%2Fyadu/lists"}