logger

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package logger is used to store details of events in the node. Events can be categorized by Debug, Info, Error, Fatal, and Panic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProductionLogger

func CreateProductionLogger(
	dir string, jsonConsole bool, lvl zapcore.Level, toDisk bool) *zap.Logger

CreateProductionLogger returns a log config for the passed directory with the given LogLevel and customizes stdout for pretty printing.

func CreateTestLogger

func CreateTestLogger() *zap.Logger

CreateTestLogger creates a logger that directs output to PrettyConsole configured for test output.

func Debug

func Debug(args ...interface{})

Debug logs a debug message.

func Debugf

func Debugf(format string, values ...interface{})

Debugf formats and then logs the message.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a debug message and any additional given information.

func Error

func Error(args ...interface{})

Error logs an error message.

func ErrorIf

func ErrorIf(err error)

ErrorIf logs the error if present.

func Errorf

func Errorf(format string, values ...interface{})

Errorf logs a message at the error level using Sprintf.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs an error message, any additional given information, and includes stack trace.

func Fatal

func Fatal(args ...interface{})

Fatal logs a fatal message then exits the application.

func Fatalf

func Fatalf(format string, values ...interface{})

Fatalf logs a message at the fatal level using Sprintf.

func Info

func Info(args ...interface{})

Info logs an info message.

func Infof

func Infof(format string, values ...interface{})

Infof formats and then logs the message.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs an info message and any additional given information.

func Panic

func Panic(args ...interface{})

Panic logs a panic message then panics.

func PanicIf

func PanicIf(err error)

PanicIf logs the error if present.

func Panicf

func Panicf(format string, values ...interface{})

Panicf formats and then logs the message before panicking.

func SetLogger

func SetLogger(zl *zap.Logger)

SetLogger sets the internal logger to the given input.

func Sync

func Sync() error

Sync flushes any buffered log entries.

func Warn

func Warn(args ...interface{})

Warn logs a message at the warn level.

func WarnIf

func WarnIf(err error)

WarnIf logs the error if present.

func Warnf

func Warnf(format string, values ...interface{})

Warnf formats and then logs the message as Warn.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a debug message and any additional given information.

Types

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger holds a field for the logger interface.

func GetLogger

func GetLogger() *Logger

func (*Logger) Write

func (l *Logger) Write(b []byte) (int, error)

Write logs a message at the Info level and returns the length of the given bytes.

type PrettyConsole

type PrettyConsole struct {
	zap.Sink
}

PrettyConsole wraps a Sink (Writer, Syncer, Closer), usually stdout, and formats the incoming json bytes with colors and white space for readability before passing on to the underlying Writer in Sink.

func (PrettyConsole) Write

func (pc PrettyConsole) Write(b []byte) (int, error)

Write reformats the incoming json bytes with colors, newlines and whitespace for better readability in console.

Jump to

Keyboard shortcuts

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