log

package
v0.1.13-profiler Latest Latest
Warning

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

Go to latest
Published: Aug 25, 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

Nop is an option that disables this logger.

Functions

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 Error

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

Error prints formatted error level log message.

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)

JSONLog sets logging to be in JSON format or not.

func Level added in v0.1.11

func Level() zapcore.Level

Level returns the zapcore level of logging.

func Panic

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

Panic writes the log message and then panics.

func Warning

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

Warning prints formatted warning level log message.

Types

type Field

type Field zap.Field

Field is a log field holding a name and value

func AtxID added in v0.1.11

func AtxID(val string) Field

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

func BlockID added in v0.1.11

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 added in v0.1.11

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

Int32 returns an int32 Field.

func LayerID added in v0.1.11

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 added in v0.1.11

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 added in v0.1.11

func TxID(val string) Field

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

func Uint32

func Uint32(name string, val uint32) Field

Uint32 returns an 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

Field satisfy loggable field interface.

type FieldLogger added in v0.1.11

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

FieldLogger is a logger that only logs messages with fields. it does not support formatting.g

func Event

func Event() FieldLogger

Event returns a field logger with the Event field set to true.

func With

func With() FieldLogger

With returns a FieldLogger which you can append fields to.

func (FieldLogger) Debug added in v0.1.11

func (fl FieldLogger) Debug(msg string, fields ...LoggableField)

Debug prints message with fields

func (FieldLogger) Error added in v0.1.11

func (fl FieldLogger) Error(msg string, fields ...LoggableField)

Error prints message with fields

func (FieldLogger) Info added in v0.1.11

func (fl FieldLogger) Info(msg string, fields ...LoggableField)

Info prints message with fields

func (FieldLogger) Warning added in v0.1.11

func (fl FieldLogger) Warning(msg string, fields ...LoggableField)

Warning prints message with fields

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

NilLogger is a not initialized logger it will panic if you'll call methods on it.

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

NewDefault creates a Log with not file output.

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

Event returns a logger with the Event field appended to it.

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{})

Panic prints the log message and then panics.

func (Log) SetLevel added in v0.1.2

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

SetLevel returns a logger with level as the log level derived from l.

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

WithFields returns a logger with fields permanently appended to it.

func (Log) WithName

func (l Log) WithName(prefix string) Log

WithName returns a logger the given fields

func (Log) WithOptions

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

WithOptions clones the current Logger, applies the supplied Options, and returns the resulting Logger. It's safe to use concurrently.

type LoggableField added in v0.1.2

type LoggableField interface {
	Field() Field
}

LoggableField as an interface to enable every type to be used as a log 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
}

Logger is an interface for our logging API.

Jump to

Keyboard shortcuts

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