logger

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoggerNameFile is unique name of the file logger.
	LoggerNameFile = "FILE"
	// LoggerNameStdOutput is the unique name of the std logger.
	LoggerNameStdOutput = "STD_OUTPUT"
	// LoggerNameDB is the unique name of the DB logger.
	LoggerNameDB = "DB"
)

Variables

This section is empty.

Functions

func DBGetterFactory added in v1.7.0

func DBGetterFactory(options ...OptionItem) (getter.Interface, error)

DBGetterFactory creates a getter for the DB logger

func DBSweeperFactory added in v1.7.0

func DBSweeperFactory(options ...OptionItem) (sweeper.Interface, error)

DBSweeperFactory creates DB sweeper.

func Debug

func Debug(v ...interface{})

Debug ...

func Debugf

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

Debugf for debuging with format

func Error

func Error(v ...interface{})

Error for logging error

func Errorf

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

Errorf for logging error with format

func Fatal

func Fatal(v ...interface{})

Fatal ...

func Fatalf

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

Fatalf for fatal error with error

func FileGetterFactory added in v1.7.0

func FileGetterFactory(options ...OptionItem) (getter.Interface, error)

FileGetterFactory creates a getter for the "FILE" logger

func FileSweeperFactory added in v1.7.0

func FileSweeperFactory(options ...OptionItem) (sweeper.Interface, error)

FileSweeperFactory creates file sweeper.

func GetLogDataGetter added in v1.7.0

func GetLogDataGetter(loggerOptions ...Option) (getter.Interface, error)

GetLogDataGetter return the 1st matched log data getter interface

loggerOptions ...Option : logger options

If failed,

configured but initialize failed: a nil log data getter and a non-nil error will be returned.
no getter configured: a nil log data getter with a nil error are returned

Otherwise, a non nil log data getter is returned with nil error.

func GetLoggerName added in v1.7.0

func GetLoggerName(l Interface) string

GetLoggerName return a logger name by Interface

func GetSweeper added in v1.7.0

func GetSweeper(context context.Context, sweeperOptions ...Option) (sweeper.Interface, error)

GetSweeper gets an unified sweeper controller for sweeping purpose.

context context.Context : system contex used to control the sweeping loops sweeperOptions ...Option : sweeper options

If failed, a nil sweeper and a non-nil error will be returned. Otherwise, a non nil sweeper is returned with nil error.

func HasGetter added in v1.7.0

func HasGetter(name string) bool

HasGetter checks if the logger with the name provides a log data getter.

func HasLogGetterConfigured added in v1.7.0

func HasLogGetterConfigured() bool

HasLogGetterConfigured checks if a log data getter is there for using

func HasSweeper added in v1.7.0

func HasSweeper(name string) bool

HasSweeper checks if the logger with the name provides a sweeper.

func Info

func Info(v ...interface{})

Info ...

func Infof

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

Infof for logging info with format

func Init added in v1.7.0

func Init(ctx context.Context) error

Init the loggers and sweepers

func IsKnownLevel added in v1.7.0

func IsKnownLevel(level string) bool

IsKnownLevel is used to check if the logger level is supported.

func IsKnownLogger added in v1.7.0

func IsKnownLogger(name string) bool

IsKnownLogger checks if the logger is supported with name.

func Retrieve added in v1.7.0

func Retrieve(logID string) ([]byte, error)

Retrieve is wrapper func for getter.Retrieve

func Warning

func Warning(v ...interface{})

Warning ...

func Warningf

func Warningf(format string, v ...interface{})

Warningf for warning with format

Types

type Closer

type Closer interface {
	// Close the opened io stream
	Close() error
}

Closer defines method to close the open io stream used by logger.

type Declaration added in v1.7.0

type Declaration struct {
	Logger  Factory
	Sweeper SweeperFactory
	Getter  GetterFactory
	// Indicate if the logger is a singleton logger
	Singleton bool
}

Declaration is used to declare a supported logger. Use this declaration to indicate what logger and sweeper will be provided.

func KnownLoggers added in v1.7.0

func KnownLoggers(name string) *Declaration

KnownLoggers return the declaration by the name

type Entry added in v1.7.0

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

Entry provides unique interfaces on top of multiple logger backends. Entry also implements @Interface.

func NewEntry added in v1.7.0

func NewEntry(loggers []Interface) *Entry

NewEntry creates a new logger Entry

func (*Entry) Close added in v1.7.0

func (e *Entry) Close() error

Close logger

func (*Entry) Debug added in v1.7.0

func (e *Entry) Debug(v ...interface{})

Debug ...

func (*Entry) Debugf added in v1.7.0

func (e *Entry) Debugf(format string, v ...interface{})

Debugf with format

func (*Entry) Error added in v1.7.0

func (e *Entry) Error(v ...interface{})

Error ...

func (*Entry) Errorf added in v1.7.0

func (e *Entry) Errorf(format string, v ...interface{})

Errorf with format

func (*Entry) Fatal added in v1.7.0

func (e *Entry) Fatal(v ...interface{})

Fatal error

func (*Entry) Fatalf added in v1.7.0

func (e *Entry) Fatalf(format string, v ...interface{})

Fatalf error

func (*Entry) Info added in v1.7.0

func (e *Entry) Info(v ...interface{})

Info ...

func (*Entry) Infof added in v1.7.0

func (e *Entry) Infof(format string, v ...interface{})

Infof with format

func (*Entry) Warning added in v1.7.0

func (e *Entry) Warning(v ...interface{})

Warning ...

func (*Entry) Warningf added in v1.7.0

func (e *Entry) Warningf(format string, v ...interface{})

Warningf with format

type Factory added in v1.7.0

type Factory func(options ...OptionItem) (Interface, error)

Factory creates a new logger based on the settings.

type GetterFactory added in v1.7.0

type GetterFactory func(options ...OptionItem) (getter.Interface, error)

GetterFactory is responsible for creating a log data getter based on the options

type Interface

type Interface interface {
	// For debuging
	Debug(v ...interface{})

	// For debuging with format
	Debugf(format string, v ...interface{})

	// For logging info
	Info(v ...interface{})

	// For logging info with format
	Infof(format string, v ...interface{})

	// For warning
	Warning(v ...interface{})

	// For warning with format
	Warningf(format string, v ...interface{})

	// For logging error
	Error(v ...interface{})

	// For logging error with format
	Errorf(format string, v ...interface{})

	// For fatal error
	Fatal(v ...interface{})

	// For fatal error with error
	Fatalf(format string, v ...interface{})
}

Interface for logger.

func DBFactory added in v1.7.0

func DBFactory(options ...OptionItem) (Interface, error)

DBFactory is factory of file logger

func FileFactory added in v1.7.0

func FileFactory(options ...OptionItem) (Interface, error)

FileFactory is factory of file logger

func GetLogger added in v1.7.0

func GetLogger(loggerOptions ...Option) (Interface, error)

GetLogger gets an unified logger entry for logging per the passed settings. The logger may built based on the multiple registered logger backends.

loggerOptions ...Option : logger options

If failed, a nil logger and a non-nil error will be returned. Otherwise, a non nil logger is returned with nil error.

func StdFactory added in v1.7.0

func StdFactory(options ...OptionItem) (Interface, error)

StdFactory is factory of std output logger.

type Option added in v1.7.0

type Option struct {
	// Apply logger option
	Apply func(op *options)
}

Option represents settings of the logger

func BackendOption added in v1.7.0

func BackendOption(name string, level string, settings map[string]interface{}) Option

BackendOption creates option for the specified backend.

func GetterOption added in v1.7.0

func GetterOption(name string, settings map[string]interface{}) Option

GetterOption creates option for the getter.

func SweeperOption added in v1.7.0

func SweeperOption(name string, duration int, settings map[string]interface{}) Option

SweeperOption creates option for the sweeper.

type OptionItem added in v1.7.0

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

OptionItem is a simple wrapper of property and value

func (*OptionItem) Field added in v1.7.0

func (o *OptionItem) Field() string

Field returns name of the option

func (*OptionItem) Int added in v1.7.0

func (o *OptionItem) Int() int

Int returns the integer value of option

func (*OptionItem) Raw added in v1.7.0

func (o *OptionItem) Raw() interface{}

Raw returns the raw value

func (*OptionItem) String added in v1.7.0

func (o *OptionItem) String() string

String returns the string value of option

type SweeperController added in v1.7.0

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

SweeperController is an unified sweeper entry and built on top of multiple sweepers. It's responsible for starting the configured sweepers.

func NewSweeperController added in v1.7.0

func NewSweeperController(ctx context.Context, sweepers []sweeper.Interface) *SweeperController

NewSweeperController is constructor of controller.

func (*SweeperController) Duration added in v1.7.0

func (c *SweeperController) Duration() int

Duration = -1 for controller

func (*SweeperController) Sweep added in v1.7.0

func (c *SweeperController) Sweep() (int, error)

Sweep logs

type SweeperFactory added in v1.7.0

type SweeperFactory func(options ...OptionItem) (sweeper.Interface, error)

SweeperFactory is responsible for creating a sweeper.Interface based on the settings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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