Documentation ¶
Index ¶
- Constants
- func Data(d any) slog.Attr
- func Error(err error) slog.Attr
- func New(cfg *LogConfiguration) (*slog.Logger, error)
- func NodeID(id peer.ID) slog.Attr
- func Round(round uint64) slog.Attr
- func UnitID(id []byte) slog.Attr
- type ABHandler
- func (h *ABHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *ABHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *ABHandler) Handler() slog.Handler
- func (h *ABHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *ABHandler) WithGroup(name string) slog.Handler
- type LogConfiguration
Constants ¶
View Source
const ( NodeIDKey = "node_id" ModuleKey = "module" GoIDKey = "go_id" ErrorKey = "err" RoundKey = "round" UnitIDKey = "unit_id" DataKey = "data" )
Log attribute key values. Generally shouldn't be used directly, use appropriate "attribute constructor function" instead.
Only define names here if they are common for multiple modules, module specific names should be defined in the module.
View Source
const (
LevelTrace slog.Level = slog.LevelDebug - 4
)
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data adds additional data field to the message.
slog.GroupValue shouldn't be used as the data - in the ECS formatter all groups will end up under the same key possibly causing problems with index!
Use of anonymous types is discouraged too.
func Error ¶
Error adds error to the log
if err:= f(); err != nil { log.Error("calling f", logger.Error(err)) }
Types ¶
type ABHandler ¶
type ABHandler struct {
// contains filtered or unexported fields
}
ABHandler is a slog handler which does some AB specific processing to the log:
- adds goroutine id field to the log record (if flag is set);
- adds trace/span id attributes (if present in the context);
type LogConfiguration ¶
type LogConfiguration struct { Level string `yaml:"defaultLevel"` Format string `yaml:"format"` OutputPath string `yaml:"outputPath"` TimeFormat string `yaml:"timeFormat"` PeerIDFormat string `yaml:"peerIdFormat"` ShowGoroutineID *bool `yaml:"showGoroutineID"` // when Format==console this func will be used to determine // whether to use color codes in log output ConsoleSupportsColor func(io.Writer) bool ConsoleFormat *bool `yaml:"consoleFormat"` // -> Format ShowNodeID *bool `yaml:"showNodeID"` // -> PeerIDFormat }
Click to show internal directories.
Click to hide internal directories.