Documentation
¶
Overview ¶
Example (AppendJSON) ¶
var buf []byte
buf = appendJSON(buf, myStruct{
Foo: "hello",
Bar: "world",
})
fmt.Println(buf[:5])
fmt.Println(string(buf[5:]))
Output: [198 0 0 0 29] {"foo":"hello","bar":"world"}
Example (CountFmtArgs) ¶
fmt.Println(countFmtArgs("start %% %[3]d %#+08x %-10.5s %[4]d %06d %d %d end"))
Output: 7
Index ¶
- type BatchWriter
- type Instance
- type KeyValueAppender
- type Logger
- func (l *Logger) Alert(msg string, args ...any) hexid.ID
- func (l *Logger) Alertf(msg string, args ...any) hexid.ID
- func (l *Logger) Crit(msg string, args ...any) hexid.ID
- func (l *Logger) Critf(msg string, args ...any) hexid.ID
- func (l *Logger) Debug(msg string, args ...any) hexid.ID
- func (l *Logger) Debugf(format string, args ...any) hexid.ID
- func (l *Logger) Emerg(msg string, args ...any) hexid.ID
- func (l *Logger) Emergf(msg string, args ...any) hexid.ID
- func (l *Logger) Error(msg string, args ...any) hexid.ID
- func (l *Logger) Errorf(format string, args ...any) hexid.ID
- func (l *Logger) Info(msg string, args ...any) hexid.ID
- func (l *Logger) Infof(format string, args ...any) hexid.ID
- func (l *Logger) Metrics(args ...any)
- func (l *Logger) Notice(msg string, args ...any) hexid.ID
- func (l *Logger) Noticef(msg string, args ...any) hexid.ID
- func (l *Logger) Recover()
- func (l *Logger) Release()
- func (l *Logger) SlogHandler() slog.Handler
- func (l *Logger) Warn(msg string, args ...any) hexid.ID
- func (l *Logger) Warnf(format string, args ...any) hexid.ID
- func (l *Logger) With(args ...any) *Logger
- type Options
- type Reconnector
- type Severity
- type WriteBehavior
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchWriter ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func NewInstance ¶
Create a logger instance used for acquiring loggers.
type KeyValueAppender ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A logger with optional meta data, which every log entry will inherit.
func (*Logger) Alertf ¶ added in v0.8.0
A person must take an action immediately. Formatted with printf syntax.
func (*Logger) Critf ¶ added in v0.8.0
Critical events cause more severe problems or outages. Formatted with printf syntax.
func (*Logger) Emergf ¶ added in v0.8.0
One or more systems are unusable. Formatted with printf syntax.
func (*Logger) Infof ¶
Routine information, such as ongoing status or performance. Formatted with printf syntax.
func (*Logger) Metrics ¶ added in v0.6.0
Logs metric values. Example usage:
log.Warn("hello world",
"myKey", 123,
"otherKey", 456,
)
func (*Logger) Notice ¶ added in v0.8.0
Normal but significant events, such as start up, shut down, or a configuration change.
func (*Logger) Noticef ¶ added in v0.8.0
Normal but significant events, such as start up, shut down, or a configuration change. Formatted with printf syntax.
func (*Logger) Recover ¶
func (l *Logger) Recover()
Recovers from a panic and logs it as a critical error. Usage:
go func() {
defer log.Recover()
panic("aaaaaahh")
}()
Example ¶
inst, err := NewInstance(io.Discard)
if err != nil {
log.Fatal(err)
}
log := inst.Logger()
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
defer log.Recover()
panic("aaaaaahh")
}()
wg.Wait()
func (*Logger) SlogHandler ¶ added in v0.8.0
Example ¶
inst, err := NewInstance(io.Discard)
if err != nil {
panic(err)
}
l := inst.Logger()
log := slog.New(l.SlogHandler())
log.Info("foobar")
type Reconnector ¶ added in v0.9.2
type Reconnector interface {
Reconnect() error
}
type WriteBehavior ¶
type WriteBehavior uint8
const ( // Any writes to a full buffer will block. // This guarantees that no logs are lost, but might block the application // until there is room in the buffer. This also means that if the client // can't write any logs at all, the application might get locked. For this // reason, this option is discouraged for clients dependent on remote hosts. Block WriteBehavior = iota // Any writes to a full buffer will be dropped immediately. // This guarantees that the application will never be blocked by logging, // but also means that log messages might be lost during busy times. Loose // Any writes to a full buffer will fallback to a compressed, disk-based // ping-pong buffer and retried later. // This guarantees that no logs neither lost nor blocking the application, but // also requires that the client implements the BatchWriter interface. This // should be the prefered option when possible. Fallback )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
cli
command
|
|
|
client
command
|
|
|
server
command
|
|
|
terminal
command
|
|
|
internal
|
|
|
gzip
Package gzip implements reading of gzip format compressed files, as specified in RFC 1952.
|
Package gzip implements reading of gzip format compressed files, as specified in RFC 1952. |
|
pkg
|
|
|
msgpack
integer.go
|
integer.go |