logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger contains interface and implementations for logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCtxWithLogger

func GetCtxWithLogger(ctx context.Context, l Logger) context.Context

GetCtxWithLogger returns derived context with given logger set. If logger is already present, it will be shadowed.

func SetupGlobal

func SetupGlobal()

SetupGlobal sets up global logrus logger.

Types

type Logger

type Logger interface {
	Sync() error
	GRPCLogger() grpclog.LoggerV2

	WithField(key string, value interface{}) Logger

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
}

Logger contains all methods related to zap and logrus loggers.

func Get

func Get(ctx context.Context) Logger

Get returns logger from given context produced by GetCtxWithLogger.

func NewLogger

func NewLogger() Logger

NewLogger returns new LogrusLogger.

type LogrusLogger

type LogrusLogger struct {
	// contains filtered or unexported fields
}

LogrusLogger iz a wrapper for logrus .Logger.

func (*LogrusLogger) Debug

func (z *LogrusLogger) Debug(args ...interface{})

func (*LogrusLogger) Debugf

func (z *LogrusLogger) Debugf(format string, args ...interface{})

func (*LogrusLogger) Error

func (z *LogrusLogger) Error(args ...interface{})

func (*LogrusLogger) Errorf

func (z *LogrusLogger) Errorf(format string, args ...interface{})

func (*LogrusLogger) Fatal

func (z *LogrusLogger) Fatal(args ...interface{})

func (*LogrusLogger) Fatalf

func (z *LogrusLogger) Fatalf(format string, args ...interface{})

func (*LogrusLogger) GRPCLogger

func (z *LogrusLogger) GRPCLogger() grpclog.LoggerV2

GRPCLogger wraps zap.Logger in grpc compatible wrapper and returns it.

func (*LogrusLogger) Info

func (z *LogrusLogger) Info(args ...interface{})

func (*LogrusLogger) Infof

func (z *LogrusLogger) Infof(format string, args ...interface{})

func (*LogrusLogger) Panic

func (z *LogrusLogger) Panic(args ...interface{})

func (*LogrusLogger) Panicf

func (z *LogrusLogger) Panicf(format string, args ...interface{})

func (*LogrusLogger) Sync

func (z *LogrusLogger) Sync() error

Sync calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.

func (*LogrusLogger) Warn

func (z *LogrusLogger) Warn(args ...interface{})

func (*LogrusLogger) Warnf

func (z *LogrusLogger) Warnf(format string, args ...interface{})

func (*LogrusLogger) WithField

func (z *LogrusLogger) WithField(key string, value interface{}) Logger

WithField Add a single field to the Logger.

type PromHTTP

type PromHTTP struct {
	L Logger
}

PromHTTP is a compatibility wrapper between Logger interface and Prometheus HTTP logger interface.

func (*PromHTTP) Println

func (p *PromHTTP) Println(args ...interface{})

Jump to

Keyboard shortcuts

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