Documentation ¶
Overview ¶
Package ctxz implements wrapper to report aggregated messages for github.com/bool64/ctxd.Logger.
Index ¶
- type Observer
- func (o Observer) CtxdLogger() ctxd.Logger
- func (o Observer) Debug(ctx context.Context, msg string, keysAndValues ...interface{})
- func (o Observer) Error(ctx context.Context, msg string, keysAndValues ...interface{})
- func (o Observer) Important(ctx context.Context, msg string, keysAndValues ...interface{})
- func (o Observer) Info(ctx context.Context, msg string, keysAndValues ...interface{})
- func (o Observer) LevelObservers() []*logz.Observer
- func (o Observer) Warn(ctx context.Context, msg string, keysAndValues ...interface{})
- func (o Observer) WithLogger(l ctxd.Logger) Observer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer keeps track of logged messages.
func NewObserver ¶
NewObserver initializes Observer instance.
Example ¶
package main import ( "context" "net/http" "os" "time" "github.com/bool64/ctxd" "github.com/bool64/logz" "github.com/bool64/logz/ctxz" "github.com/bool64/logz/logzpage" ) func main() { var logger ctxd.Logger lz := ctxz.NewObserver(logger, logz.Config{ MaxCardinality: 100, MaxSamples: 50, DistRetentionPeriod: 72 * time.Hour, }) logger = lz ctx := context.TODO() logger.Debug(ctx, "starting example") logger.Info(ctx, "sample info", "one", 1, "two", 2) logger.Error(ctx, "unexpected end of the world") logger.Important(ctx, "starting server at http://localhost:6060/") err := http.ListenAndServe("0.0.0.0:6060", logzpage.Handler(lz.LevelObservers()...)) if err != nil { logger.Error(ctx, err.Error()) os.Exit(1) } }
Output:
func (Observer) CtxdLogger ¶
CtxdLogger is a service provider.
func (Observer) LevelObservers ¶
LevelObservers returns .
Click to show internal directories.
Click to hide internal directories.