logger

package
v1.8.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// NameFile is unique name of the file logger.
	NameFile = "FILE"
	// NameStdOutput is the unique name of the std logger.
	NameStdOutput = "STD_OUTPUT"
	// NameDB is the unique name of the DB logger.
	NameDB = "DB"
)

Variables

This section is empty.

Functions

func DBGetterFactory

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

DBGetterFactory creates a getter for the DB logger

func DBSweeperFactory

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

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

FileGetterFactory creates a getter for the "FILE" logger

func FileSweeperFactory

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

FileSweeperFactory creates file sweeper.

func GetLogDataGetter

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

func GetLoggerName(l Interface) string

GetLoggerName return a logger name by Interface

func GetSweeper

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

func HasGetter(name string) bool

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

func HasSweeper

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

func Init(ctx context.Context) error

Init the loggers and sweepers

func IsKnownLevel

func IsKnownLevel(level string) bool

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

func IsKnownLogger

func IsKnownLogger(name string) bool

IsKnownLogger checks if the logger is supported with name.

func Retrieve

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

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

func KnownLoggers(name string) *Declaration

KnownLoggers return the declaration by the name

type Entry

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

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

func NewEntry

func NewEntry(loggers []Interface) *Entry

NewEntry creates a new logger Entry

func (*Entry) Close

func (e *Entry) Close() error

Close logger

func (*Entry) Debug

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

Debug ...

func (*Entry) Debugf

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

Debugf with format

func (*Entry) Error

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

Error ...

func (*Entry) Errorf

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

Errorf with format

func (*Entry) Fatal

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

Fatal error

func (*Entry) Fatalf

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

Fatalf error

func (*Entry) Info

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

Info ...

func (*Entry) Infof

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

Infof with format

func (*Entry) Warning

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

Warning ...

func (*Entry) Warningf

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

Warningf with format

type Factory

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

Factory creates a new logger based on the settings.

type GetterFactory

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

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

DBFactory is factory of file logger

func FileFactory

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

FileFactory is factory of file logger

func GetLogger

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

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

StdFactory is factory of std output logger.

type Option

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

Option represents settings of the logger

func BackendOption

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

BackendOption creates option for the specified backend.

func GetterOption

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

GetterOption creates option for the getter.

func SweeperOption

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

SweeperOption creates option for the sweeper.

type OptionItem

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

OptionItem is a simple wrapper of property and value

func (*OptionItem) Field

func (o *OptionItem) Field() string

Field returns name of the option

func (*OptionItem) Int

func (o *OptionItem) Int() int

Int returns the integer value of option

func (*OptionItem) Raw

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

Raw returns the raw value

func (*OptionItem) String

func (o *OptionItem) String() string

String returns the string value of option

type SweeperController

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

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

NewSweeperController is constructor of controller.

func (*SweeperController) Duration

func (c *SweeperController) Duration() int

Duration = -1 for controller

func (*SweeperController) Sweep

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

Sweep logs

type SweeperFactory

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