logutil

package
v2.189.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Overview

Example (Logall)
package main

import (
	"berty.tech/berty/v2/go/internal/logutil"
)

func main() {
	logger, cleanup, err := logutil.NewLogger("*", "light-console", "stdout")
	if err != nil {
		panic(err)
	}
	defer cleanup()

	logger.Debug("top debug")
	logger.Info("top info")
	logger.Warn("top warn")
	logger.Error("top error")

	logger.Named("foo").Debug("foo debug")
	logger.Named("foo").Info("foo info")
	logger.Named("foo").Warn("foo warn")
	logger.Named("foo").Error("foo error")

}
Output:

DEBUG	bty               	top debug
INFO 	bty               	top info
WARN 	bty               	top warn
ERROR	bty               	top error
DEBUG	bty.foo           	foo debug
INFO 	bty.foo           	foo info
WARN 	bty.foo           	foo warn
ERROR	bty.foo           	foo error
Example (Logerrors)
package main

import (
	"berty.tech/berty/v2/go/internal/logutil"
)

func main() {
	logger, cleanup, err := logutil.NewLogger("error:*,-*.bar warn:*.bar", "light-console", "stdout")
	if err != nil {
		panic(err)
	}
	defer cleanup()

	logger.Debug("top debug")
	logger.Info("top info")
	logger.Warn("top warn")
	logger.Error("top error")

	logger.Named("foo").Debug("foo debug")
	logger.Named("foo").Info("foo info")
	logger.Named("foo").Warn("foo warn")
	logger.Named("foo").Error("foo error")

	logger.Named("foo").Named("bar").Debug("foo.bar debug")
	logger.Named("foo").Named("bar").Info("foo.bar info")
	logger.Named("foo").Named("bar").Warn("foo.bar warn")
	logger.Named("foo").Named("bar").Error("foo.bar error")

}
Output:

ERROR	bty               	top error
ERROR	bty.foo           	foo error
WARN 	bty.foo.bar       	foo.bar warn

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecorateLogger

func DecorateLogger(base *zap.Logger, filters string) (*zap.Logger, func(), error)

func NewLogger

func NewLogger(filters string, format string, logFile string) (*zap.Logger, func(), error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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