logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseDataDir = "data"
	LogsDir     = "logs"
)

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(env LogLevel, processName ProcessName) error

InitLogger initializes a logger for a specific process with production environment by default

Types

type LogLevel

type LogLevel string
const (
	Development LogLevel = "development" // prints debug and above
	Production  LogLevel = "production"  // prints info and above
)

type Logger

type Logger interface {
	Debug(msg string, tags ...any)

	Info(msg string, tags ...any)

	Warn(msg string, tags ...any)

	Error(msg string, tags ...any)

	Fatal(msg string, tags ...any)

	Debugf(template string, args ...interface{})

	Infof(template string, args ...interface{})

	Warnf(template string, args ...interface{})

	Errorf(template string, args ...interface{})

	Fatalf(template string, args ...interface{})

	With(tags ...any) Logger
}

func GetLogger

func GetLogger(env LogLevel, processName ProcessName) Logger

GetLogger returns the logger for a specific process

func NewZapLogger

func NewZapLogger(env LogLevel, processName string) (Logger, error)

NewZapLogger creates a new logger wrapped the zap.Logger

func NewZapLoggerByConfig

func NewZapLoggerByConfig(config zap.Config, options ...zap.Option) (Logger, error)

NewZapLoggerByConfig creates a logger wrapped the zap.Logger Note if the logger need to show the caller, need use `zap.AddCallerSkip(1)` ad options

type ProcessName

type ProcessName string

ProcessName type to ensure valid process names

const (
	ManagerProcess   ProcessName = "manager"
	QuorumProcess    ProcessName = "quorum"
	ValidatorProcess ProcessName = "validator"
	DatabaseProcess  ProcessName = "database"
	KeeperProcess    ProcessName = "keeper"
)

type ZapLogger

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

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(msg string, tags ...any)

func (*ZapLogger) Debugf

func (z *ZapLogger) Debugf(template string, args ...interface{})

func (*ZapLogger) Error

func (z *ZapLogger) Error(msg string, tags ...any)

func (*ZapLogger) Errorf

func (z *ZapLogger) Errorf(template string, args ...interface{})

func (*ZapLogger) Fatal

func (z *ZapLogger) Fatal(msg string, tags ...any)

func (*ZapLogger) Fatalf

func (z *ZapLogger) Fatalf(template string, args ...interface{})

func (*ZapLogger) Info

func (z *ZapLogger) Info(msg string, tags ...any)

func (*ZapLogger) Infof

func (z *ZapLogger) Infof(template string, args ...interface{})

func (*ZapLogger) Warn

func (z *ZapLogger) Warn(msg string, tags ...any)

func (*ZapLogger) Warnf

func (z *ZapLogger) Warnf(template string, args ...interface{})

func (*ZapLogger) With

func (z *ZapLogger) With(tags ...any) Logger

Jump to

Keyboard shortcuts

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