logging

package
v0.0.0-...-675d107 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ExceptionFieldName = "exception"

ExceptionFieldName is the field name used for exception fields. In our case, it should be a sentry-formatted exception built from a panic

Variables

This section is empty.

Functions

func DefaultLogger

func DefaultLogger(output io.Writer) zerolog.Logger

DefaultLogger ...

func PrintFrame

func PrintFrame(frame sentry.Frame) string

PrintFrame prints a sentry frame in a go stack-like manner

Types

type ConsoleWriter

type ConsoleWriter struct {
	// Out is the output destination.
	Out io.Writer

	// NoColor disables the colorized output.
	NoColor bool

	// TimeFormat specifies the format for timestamp in output.
	TimeFormat string

	// PartsOrder defines the order of parts in output.
	PartsOrder []string

	FormatTimestamp     Formatter
	FormatLevel         Formatter
	FormatCaller        Formatter
	FormatMessage       Formatter
	FormatFieldName     Formatter
	FormatFieldValue    Formatter
	FormatErrFieldName  Formatter
	FormatErrFieldValue Formatter
	FormatExcFieldName  Formatter
	FormatExcFieldValue Formatter
}

ConsoleWriter parses the JSON input and writes it in an (optionally) colorized, human-friendly format to Out.

func NewConsoleWriter

func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter

NewConsoleWriter creates and initializes a new ConsoleWriter.

func (ConsoleWriter) Write

func (w ConsoleWriter) Write(p []byte) (n int, err error)

Write transforms the JSON input with formatters and appends to w.Out.

type Formatter

type Formatter func(interface{}) string

Formatter transforms the input into a formatted string.

type Options

type Options struct {
	Level   func(string) error `` /* 265-byte string literal not displayed */
	Format  func(string) error `` /* 178-byte string literal not displayed */
	Verbose func()             `short:"v" long:"verbose" no-ini:"t" description:"Increase log verbosity. Can be repeated"`
	// contains filtered or unexported fields
}

Options holds the logging options

func MustOptions

func MustOptions(o *Options, err error) *Options

MustOptions panic if err is not nil

func NewOptions

func NewOptions(log *zerolog.Logger, output io.Writer) (*Options, error)

NewOptions creates a new Options struct for obtaining a logger

func (*Options) AddLogWrapper

func (o *Options) AddLogWrapper(wrapper func(io.Writer) io.Writer)

AddLogWrapper adds a log wrapper to the stack

func (*Options) Logger

func (o *Options) Logger() zerolog.Logger

Logger returns the latest configured logger

func (*Options) SetMinLoggingLevel

func (o *Options) SetMinLoggingLevel(level zerolog.Level)

SetMinLoggingLevel makes sure the logging level is not under a given value

func (*Options) Setup

func (o *Options) Setup(log *zerolog.Logger, output io.Writer) error

Setup ...

Source Files

  • log-console-writer.go
  • log.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL