Documentation
¶
Index ¶
- Variables
- func Debugf(format string, args ...any)
- func Errorf(format string, args ...any)
- func Printf(format string, args ...any)
- func Warnf(format string, args ...any)
- type Data
- type Handler
- type Level
- type Logger
- func (l *Logger) Debugf(text string, args ...any)
- func (l *Logger) Errorf(text string, args ...any)
- func (l *Logger) Handlers(h ...Handler) *Logger
- func (l *Logger) Infof(text string, args ...any)
- func (l *Logger) Options(o Option) *Logger
- func (l *Logger) Printf(text string, args ...any)
- func (l *Logger) Tag(name string) *Logger
- func (l *Logger) Trace(depth int) *Logger
- func (l *Logger) Verbosity(m Level) *Logger
- func (l *Logger) Warnf(text string, args ...any)
- func (l *Logger) Write(p []byte) (n int, err error)
- type Message
- func (m Message) CreatedAt() time.Time
- func (m Message) Fields() Data
- func (m Message) Location(colors bool) string
- func (m Message) MarshalJSON() ([]byte, error)
- func (m Message) MarshalText() ([]byte, error)
- func (m Message) Render(o Option) ([]byte, error)
- func (m Message) String() string
- func (m Message) Tag(colors bool) string
- func (m Message) Text(colors, properties bool) string
- func (m Message) Type(colors bool) string
- type Option
Constants ¶
This section is empty.
Variables ¶
var Default = New(os.Stdout, All)
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger support three types(levels) of logging
INF - default, when you want emphasize that something important (not negative) has happened. It should be used for informing about rare situation in your code, such as database connection has been established.
DBG - it meant to be verbose, like every few lines of code, when you decide that part of your code implementation did something important for internal state of your library/code.
ERR - when your code is a place where error is received but there is no good way of handling that situation you might log it todo
- default attributes data added to each Message
- log.Format option
func New ¶
New instance of logger
io.Writer w will receive all messages that are generated internally from strings and arguments that are passed to Logger.Printf.
Option o represents what is going to be included in strings that are passed into io.Writer
func (*Logger) Handlers ¶
Handlers creates new instance of Logger and all Message's are passed into Handler just after it is writer to io.Writer
func (*Logger) Printf ¶
Printf when text is json format and has no arguments a then it will be transformed
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func (Message) MarshalJSON ¶
func (Message) MarshalText ¶ added in v1.0.4
type Option ¶
type Option int64
Option ...
const ( // Date render Message with date in 2006/01/02 format Date Option = 1 << iota // Time render Message with time in 15:04:05.000000 format Time // Levels render Message with one of INF, DBG, ERR strings Levels // Tags render Message with tag name Tags // Trace render Message with filename and line number Trace // Properties renders %v data in a Message output string Properties // Colors render Message with colors Colors // JSON makes output with json format instead text JSON All = Date | Time | Levels | Tags | Trace | Properties | Colors )
