logger

package
v0.0.0-...-17369de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Overview

Package logger manages loggers used in dragonboat.

Index

Constants

View Source
const (
	// RepoName is the repo name used in capnslog.
	RepoName = "github.com/LiuzhouChan/go-paxos"
)

Variables

This section is empty.

Functions

func DescribeNode

func DescribeNode(groupID uint64, nodeID uint64) string

DescribeNode returns the string representation of a node with known group id and node id values.

func DescribeSM

func DescribeSM(groupID uint64, nodeID uint64) string

DescribeSM returns the string representation of a State Machine object with known group id and node id values.

func GroupID

func GroupID(groupID uint64) string

GroupID returns the string representation of a cluster id value

func NodeID

func NodeID(nodeID uint64) string

NodeID returns the string representation of a node id value.

func SetLoggerFactory

func SetLoggerFactory(f Factory)

SetLoggerFactory sets the factory function used to create ILogger instances.

Types

type Factory

type Factory func(pkgName string) ILogger

Factory is the factory method for creating logger used for the specified package.

type ILogger

type ILogger interface {
	SetLevel(LogLevel)
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
}

ILogger is the interface implemented by loggers that can be used by dragonboat. You can implement your own ILogger implementation by building wrapper struct on top of your favourite logging library.

func CreateCapnsLog

func CreateCapnsLog(pkgName string) ILogger

CreateCapnsLog creates an ILogger instance based on capnslog.

func CreateLogrusLog

func CreateLogrusLog(pkgName string) ILogger

CreateLogrusLog creates an ILogger instance based on logrus

func GetLogger

func GetLogger(pkgName string) ILogger

GetLogger returns the logger for the specified package name. The most common use case for the returned logger is to set its log verbosity level.

type LogLevel

type LogLevel int

LogLevel is the log level defined in dragonboat.

const (
	// CRITICAL is the CRITICAL log level
	CRITICAL LogLevel = iota - 1
	// ERROR is the ERROR log level
	ERROR
	// WARNING is the WARNING log level
	WARNING
	// INFO is the INFO log level
	INFO
	// DEBUG is the DEBUG log level
	DEBUG
)

Jump to

Keyboard shortcuts

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