Skip to content

Commit

Permalink
document the slag package (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <[email protected]>
  • Loading branch information
imjasonh authored Aug 9, 2024
1 parent b42aea8 commit f6c22ba
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit f6c22ba

Please sign in to comment.