Documentation ¶
Index ¶
- type Closer
- type Event
- func (t *Event) Caller() *Event
- func (t *Event) Discard()
- func (t *Event) Err(err error) *Event
- func (t *Event) Field(key, value any) *Event
- func (t *Event) Fields(kv ...any) *Event
- func (t *Event) Msg(v string) error
- func (t *Event) Msgf(format string, args ...any) error
- func (t *Event) Reset()
- func (t *Event) Send() error
- func (t *Event) Tag(tag string) *Event
- type Field
- type JsonWriter
- type Logger
- type MultiWriter
- type PrettyWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is used to build and send log messages.
func (*Event) Discard ¶
func (t *Event) Discard()
Discard simply throws away the event and gives back the used resources.
This should always be called when an event will not be commited.
func (*Event) Fields ¶
Fields adds passed value alternating as keys and values to the events fields.
When an odd number of values is passed, the last field's value will be nil.
Example:
rogu.Info().Fields( "name", "Bob", "age", 24, "hobbies", []stirng{"biking", "football", "gaming"}, )
func (*Event) Msg ¶
Msg commits the event to the writer with the given message string returning an error when the log writing failed.
type JsonWriter ¶
type JsonWriter struct { Output io.Writer TimeFormat string // contains filtered or unexported fields }
JsonWriter implements Writer for JSON formatted entry output.
func NewJsonWriter ¶
func NewJsonWriter(outputs ...io.Writer) *JsonWriter
NewJsonWriter returns a new JsonWriter with the passed target output writers.
func (*JsonWriter) Close ¶
func (t *JsonWriter) Close() error
type Logger ¶
type Logger interface { Closer AddWriter(w Writer) Logger Copy() *logger Debug() *Event Error() *Event Fatal() *Event Info() *Event Panic() *Event SetCaller(enable bool) Logger SetLevel(lvl level.Level) Logger SetWriter(w Writer) Logger Tagged(tag string) Logger Trace() *Event Warn() *Event WithLevel(lvl level.Level) *Event }
Logger is used to create log events and to specify writers which are used to write commited events.
type MultiWriter ¶
type MultiWriter []Writer
MultiWriter writes events to multiple registered writers.
func (MultiWriter) Close ¶ added in v0.3.0
func (t MultiWriter) Close() error
Close closes the set writers or all writers that are added to the logger and which are closable.
type PrettyWriter ¶
type PrettyWriter struct { Output io.Writer NoColor bool TimeFormat string StyleTimestamp lipgloss.Style StyleLevelPanic lipgloss.Style StyleLevelFatal lipgloss.Style StyleLevelError lipgloss.Style StyleLevelWarn lipgloss.Style StyleLevelInfo lipgloss.Style StyleLevelDebug lipgloss.Style StyleLevelTrace lipgloss.Style StyleCaller lipgloss.Style StyleTag lipgloss.Style StyleFieldKey lipgloss.Style StyleFieldValue lipgloss.Style StyleFieldMultipleKey lipgloss.Style StyleFieldMultipleValue lipgloss.Style StyleFieldErrorKey lipgloss.Style StyleFieldErrorValue lipgloss.Style StyleMessage lipgloss.Style // contains filtered or unexported fields }
PrettyWriter implements Writer for human readable, colorful, structured console output.
You can set NoColor to true to supress colorful formatting.
With setting TimeFormat you specify the format of the timestamp and time.Time field values. When TimeFormat is set to an empty string, no timestamp will be printed.
If you want to alter the style of the output, feel free to set custom definitions for the defined styles.
func NewPrettyWriter ¶
func NewPrettyWriter(outputs ...io.Writer) *PrettyWriter
NewPrettyWriter returns a new instance of PrettyWriter with the given output writers. When no writers are specified, os.Stdout will be used.
func (*PrettyWriter) Close ¶
func (t *PrettyWriter) Close() error