Documentation
¶
Index ¶
- Constants
- func AsStrings[T any](input []T) []string
- func WithDate(format string) option
- func WithTarget(out io.Writer) option
- type Plain
- func (p *Plain) Close() error
- func (p *Plain) Confirm(prompt string, defaultYes bool) (bool, error)
- func (p *Plain) Debug(a ...any)
- func (p *Plain) Debugf(format string, a ...any)
- func (p *Plain) Debugln(a ...any)
- func (p *Plain) Error(a ...any)
- func (p *Plain) Errorf(format string, a ...any)
- func (p *Plain) Errorln(a ...any)
- func (p *Plain) LogRequest(request *http.Request, metrics *httpsnoop.Metrics)
- func (p *Plain) Middleware() func(http.Handler) http.Handler
- func (p *Plain) MustExit(err error)
- func (p *Plain) MustFail(err error)
- func (p *Plain) Print(a ...any)
- func (p *Plain) Printf(format string, a ...any)
- func (p *Plain) Println(a ...any)
- func (p *Plain) Read(prompt string, max int) (string, error)
- func (p *Plain) ReadOne(prompt string) (rune, error)
- func (p *Plain) Select(prompt string, options []string) (int, error)
- func (p *Plain) WaitForInterrupt(close bool) error
- func (p *Plain) Warn(a ...any)
- func (p *Plain) Warnf(format string, a ...any)
- func (p *Plain) Warnln(a ...any)
- func (p *Plain) Write(code, msg string, reset, nl bool)
- type Theme
Constants ¶
const ( // RFC3339Local is an RFC3339-like time format without timezone information RFC3339Local = "2006-01-02T15:04:05" // Reset resets ANSI styling to default Reset = "\x1b[0m" )
const ( ModeNone = iota - 1 ModeSome Mode8Bit ModeFull )
Variables ¶
This section is empty.
Functions ¶
func WithDate ¶
func WithDate(format string) option
WithDate sets the timestamp format used in log headers (empty disables timestamps)
func WithTarget ¶
WithTarget sets the output writer used by the logger
Types ¶
type Plain ¶
type Plain struct {
// contains filtered or unexported fields
}
Plain is a small, allocation-conscious logger with optional ANSI color output
func New ¶
func New(opts ...option) *Plain
New creates a Plain logger configured by the provided options
func (*Plain) Close ¶
Close runs any registered closers and closes the underlying writer when supported
func (*Plain) Confirm ¶
Confirm displays a prompt aligned with the logger's format and reads y/n confirmation from stdin.
func (*Plain) Debug ¶
Debug formats using the default formats for its operands and writes to the target output as a debug log.
func (*Plain) Debugf ¶
Debugf formats according to a format specifier and writes to the target output as a debug log.
func (*Plain) Debugln ¶
Debugln formats using the default formats for its operands and writes to the target output as a debug log with a trailing newline.
func (*Plain) Error ¶
Error formats using the default formats for its operands and writes to the target output as an error.
func (*Plain) Errorf ¶
Errorf formats according to a format specifier and writes to the target output as an error.
func (*Plain) Errorln ¶
Errorln formats using the default formats for its operands and writes to the target output as an error with a trailing newline.
func (*Plain) LogRequest ¶
LogRequest writes a single formatted access log line for request using the provided metrics
func (*Plain) Middleware ¶
Middleware returns an http middleware that logs each request after it has been handled
func (*Plain) MustExit ¶ added in v1.1.5
MustExit logs the error and exits with code 1 if the error is not nil.
func (*Plain) Print ¶
Print formats using the default formats for its operands and writes to the target output.
func (*Plain) Printf ¶
Printf formats according to a format specifier and writes to the target output.
func (*Plain) Println ¶
Println formats using the default formats for its operands and writes to the target output with a trailing newline.
func (*Plain) Read ¶
Read displays a prompt aligned with the logger's format and reads max bytes from stdin.
func (*Plain) ReadOne ¶
ReadOne displays a prompt aligned with the logger's format and reads 1 byte from stdin.
func (*Plain) WaitForInterrupt ¶ added in v1.1.6
WaitForInterrupt blocks until SIGINT or SIGTERM is received and optionally closes the logger
func (*Plain) Warn ¶
Warn formats using the default formats for its operands and writes to the target output as a warning.
func (*Plain) Warnf ¶
Warnf formats according to a format specifier and writes to the target output as a warning.