log

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 9 Imported by: 29

Documentation

Overview

Package log provides the both file and console (general) logging capabilities to spacemesh modules such as app and identity.

Index

Constants

This section is empty.

Variables

View Source
var DebugLevel = zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
	return lvl >= zapcore.DebugLevel
})
View Source
var ErrorLevel = zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
	return lvl >= zapcore.ErrorLevel
})
View Source
var InfoLevel = zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
	return lvl >= zapcore.InfoLevel
})

Functions

func AddDynamicLevel

func AddDynamicLevel(level *zap.AtomicLevel) zap.Option

func Debug

func Debug(msg string, args ...interface{})

Debug prints formatted debug level log message.

func DebugMode

func DebugMode(mode bool)

DebugMode sets log debug level

func EnableLevelOption

func EnableLevelOption(enabler zapcore.LevelEnabler) zap.Option

func Error

func Error(msg string, args ...interface{})

Error prints formatted error level log message.

func Event

func Event() fieldLogger

func Info

func Info(msg string, args ...interface{})

Info prints formatted info level log message.

func InitSpacemeshLoggingSystem

func InitSpacemeshLoggingSystem(dataFolderPath string, logFileName string)

InitSpacemeshLoggingSystem initializes app logging system.

func JSONLog

func JSONLog(b bool)

func LogLvl

func LogLvl() zapcore.Level

func Panic

func Panic(msg string, args ...interface{})

func Warning

func Warning(msg string, args ...interface{})

Warning prints formatted warning level log message.

func With

func With() fieldLogger

Types

type Field

type Field zap.Field

Field is a log field holding a name and value

func AtxId

func AtxId(val string) Field

AtxId return a String field (key - "atx_id")

func BlockId

func BlockId(val string) Field

BlockId return a Uint64 field (key - "block_id")

func Bool

func Bool(name string, val bool) Field

Bool returns a bool field

func ByteString

func ByteString(name string, val []byte) Field

ByteString returns a byte string ([]byte) Field

func Duration

func Duration(name string, val time.Duration) Field

Duration returns a duration field

func EpochId

func EpochId(val uint64) Field

EpochId return a Uint64 field (key - "epoch_id")

func Err

func Err(v error) Field

Err returns an error field

func Int

func Int(name string, val int) Field

Int returns an int Field

func Int32

func Int32(name string, val int32) Field

func LayerId

func LayerId(val uint64) Field

LayerId return a Uint64 field (key - "layer_id")

func Namespace

func Namespace(name string) Field

Namespace make next fields be inside a namespace.

func NodeId

func NodeId(val string) Field

NodeId return a String field (key - "node_id")

func String

func String(name, val string) Field

String returns a string Field

func TxId

func TxId(val string) Field

TxId return a String field (key - "tx_id")

func Uint32

func Uint32(name string, val uint32) Field

func Uint64

func Uint64(name string, val uint64) Field

Uint64 returns an uint64 Field

func (Field) Field added in v0.1.2

func (f Field) Field() Field

type Log

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

Log is an exported type that embeds our logger.

var AppLog Log

AppLog is the local app singleton logger.

var NilLogger Log

func New

func New(module string, dataFolderPath string, logFileName string) Log

New creates a logger for a module. e.g. p2p instance logger.

func NewDefault

func NewDefault(module string) Log

func NewWithErrorLevel

func NewWithErrorLevel(module string, dataFolderPath string, logFileName string) Log

New creates a logger for a module. e.g. p2p instance logger.

func (Log) Debug

func (l Log) Debug(format string, args ...interface{})

Debug prints formatted debug level log message.

func (Log) Error

func (l Log) Error(format string, args ...interface{})

Error prints formatted error level log message.

func (Log) Event

func (l Log) Event() fieldLogger

func (Log) Info

func (l Log) Info(format string, args ...interface{})

Info prints formatted info level log message.

func (Log) Panic

func (l Log) Panic(format string, args ...interface{})

func (Log) SetLevel added in v0.1.2

func (l Log) SetLevel(level *zap.AtomicLevel) Log

func (Log) Warning

func (l Log) Warning(format string, args ...interface{})

Warning prints formatted warning level log message.

func (Log) With

func (l Log) With() fieldLogger

With returns a logger object that logs fields

func (Log) WithFields

func (l Log) WithFields(fields ...LoggableField) Log

func (Log) WithName

func (l Log) WithName(prefix string) Log

LogWith returns a logger the given fields

func (Log) WithOptions

func (l Log) WithOptions(opts ...zap.Option) Log

type LoggableField added in v0.1.2

type LoggableField interface {
	Field() Field
}

type Logger

type Logger interface {
	Info(format string, args ...interface{})
	Debug(format string, args ...interface{})
	Error(format string, args ...interface{})
	Warning(format string, args ...interface{})
	WithName(prefix string) Log
}

Jump to

Keyboard shortcuts

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