Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document the slag package #22

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions slag/flag.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Package slag provides a method for setting the log level from the command line.
//
// func main() {
// var level slag.Level
// flag.Var(&level, "log-level", "log level")
// flag.Parse()
// slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: &level})))
// }
//
// See [./examples/logger](./examples/logger) for a full example.
//
// This allows the log level to be set from the command line:
//
// $ ./myprogram -log-level=debug
//
// The slag.Level type is a wrapper around slog.Level that implements the flag.Value interface.
package slag

import "log/slog"
Expand Down
Loading