{"repo":"go-simpler/sloggen","free":true,"listed":false,"github":"https://github.com/go-simpler/sloggen","clone":"git clone https://github.com/go-simpler/sloggen.git","description":"🪵 Generate domain-specific wrappers for log/slog","language":"Go","stars":29,"topics":["codegen","go","slog","logging","tool"],"license":"MPL-2.0","category":"dev-tools","readme_excerpt":"sloggen Generate domain-specific wrappers for log/slog . 📌 About When using log/slog in a production-grade project, it is useful to write helpers to prevent typos in the keys: Depending on your code style, these can be simple constants (if you prefer key-value pairs)... ...or custom slog.Attr constructors (if you're a safety/performance advocate): sloggen generates such helpers for you, so you don't have to write them manually. --- The default log/slog levels cover most use cases, but at some point you may want to introduce custom levels that better suit your app. At first glance, this is as simple as defining a constant: However, custom levels are treated differently than the first-class citizens Debug / Info / Warn / Error : sloggen solves this inconvenience by generating not only the levels themselves, but also the necessary helpers. Unfortunately, the only way to use such levels is the Log method, which is quite verbose. sloggen can generate a custom Logger type so that custom levels can be used just like the builtin ones: Additionally, there are options to choose the API style of the arguments ( ...any or ...slog.Attr ) and to add/remove context.Context as the first parameter. This allows you to adjust the logging API to your own code style without sacrificing convenience. [!tip] Various API rules for log/slog can be enforced by the [ sloglint ][1] linter. Give it a try too! 🚀 Features Generate key constants and slog.Attr constructors Generate custom levels with helper","default_branch":null,"files":null,"tree":[],"storefront":"/r/go-simpler","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/go-simpler/sloggen/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}