github.com/sei-protocol/seilog
Package seilog provides structured logging with per-logger level control, built on top of log/slog. seilog adds two things standard slog does not offer out of the box: hierarchical logger naming and the ability to change log levels at runtime without restarting the process. Every logger created through NewLogger returns a plain *slog.Logger, so callers use the standard library API they already know — there is no wrapper type and no lock-in. Logger names form a hierarchy separated by "/". The recommended convention is to mirror your module or package structure so that names are globally unique, predictable, and easy to target with glob patterns: Each segment must match the pattern [a-z0-9]+(-[a-z0-9]+)*. This is enforced at creation time via panic. The constraint exists for three reasons: Use the variadic form of NewLogger rather than embedding "/" directly in a segment name. The variadic form makes the hierarchy explicit and is validated per-segment. Good: "myapp", "http-server", "myapp/db/pool" Bad: "MyApp", "my app", "", "myapp//db" Levels can be changed at runtime per logger or by pattern, and queried for diagnostics: Glob patterns follow path.Match semantics. Each "*" matches a single path segment and does not cross "/" boundaries: seilog extends standard glob matching with two special patterns: To change the baseline level for loggers that have not yet been created, use SetDefaultLevel. To inspect all registered logger names (e.g. for an admin endpoint), use ListLoggers. Output format, destination, and source-location recording are configured once at process startup through environment variables. These settings are read during package init and cannot be changed afterward; the handler is captured by each logger at creation time. When SEI_LOG_OUTPUT points to a file, call Close during graceful shutdown to flush and close the file descriptor. Close is safe to call multiple times and is a no-op for stdout and stderr. If Close is not called, the operating system will close the descriptor on process exit, but buffered data may be lost.
proxy.golang.org
v0.0.1
13 days ago
1
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/sei-protocol/seilog
spec |
| License | Apache-2.0 |
| Namespace | github.com/sei-protocol |
| First Release | 13 days ago |
| Last Synced | 12 days ago |