zzap

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package zzap provides zpage observer for "go.uber.org/zap" logger.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOption

func NewOption(cfg logz.Config) (zap.Option, []*logz.Observer)

NewOption creates zap option with per-level observers.

Example
package main

import (
	"net/http"

	"github.com/bool64/logz"
	"github.com/bool64/logz/logzpage"
	"github.com/bool64/logz/zzap"
	"go.uber.org/zap"
)

func main() {
	zc := zap.NewDevelopmentConfig()
	zz, lo := zzap.NewOption(logz.Config{
		MaxCardinality: 5,
		MaxSamples:     10,
	})

	l, err := zc.Build(zz)
	if err != nil {
		panic(err)
	}

	l.Debug("starting example")
	l.Sugar().Infow("sample info", "one", 1, "two", 2)
	l.Error("unexpected end of the world")

	l.Info("starting server at http://localhost:6060/")

	err = http.ListenAndServe("0.0.0.0:6060", logzpage.Handler(lo...))
	if err != nil {
		l.Fatal(err.Error())
	}
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL