Documentation
¶
Index ¶
- Constants
- func Init(level slog.Level)
- func New(opts slog.HandlerOptions, writers ...io.Writer) (*slog.Logger, error)
- func NewWithHandlers(opts slog.HandlerOptions, extra ...slog.Handler) (*slog.Logger, error)
- func WaitSpinner(ctx context.Context, message string, s spinner) (*sync.WaitGroup, context.CancelCauseFunc)
- type SlogHandler
- type TUI
Constants ¶
const ( IconDebug = "🔷" IconInfo = "🟢" IconWarn = "🟨" IconError = "❌" IconRun = "▶" )
const ISO8601 = "2006-01-02T15:04:05.000Z"
Variables ¶
This section is empty.
Functions ¶
func Init ¶ added in v0.2.0
Init puts a pretty custom handler on otherwise standard log/slog. WARN:this is the old way of doing it, not preferred. (Why? Delete?)
func New ¶
New creates a new slog.Logger with a tint handler that defaults to stderr. If empty slog.HandlerOptions are provided, env var DEBUG is checked. If DEBUG is unset:
- Level: slog.LevelInfo
- AddSource: false.
If DEBUG is set:
- Level: slog.LevelDebug
- AddSource: true.
NO_COLOR environment variable disables color output.
func NewWithHandlers ¶ added in v1.2.0
NewWithHandlers creates a logger that fans out to the default tint handler (stderr) plus any additional slog.Handlers, such as an OpenTelemetry log handler. Equivalent to New when no extras are given.
func WaitSpinner ¶ added in v0.2.0
func WaitSpinner(ctx context.Context, message string, s spinner) (*sync.WaitGroup, context.CancelCauseFunc)
WaitSpinner creates a new spinner, providing a wait group and spinner cancel function. Use it to provide a visual indication of a long running process.
ctx := context.Background()
// start a spinner
wg, cancel := WaitSpinner(, "waiting on foo", runner)
defer wg.Wait()
_, err := doSomething()
// stop the spinner with err values (nil means success)
cancel(err)
// then handle error as normal
if err != nil {
// handle error
}
Types ¶
type SlogHandler ¶ added in v0.2.0
type SlogHandler struct {
// contains filtered or unexported fields
}