logx

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 11 Imported by: 10

Documentation

Overview

Package logx provides ...

Package logx provides ...

Package logx provides ...

Index

Constants

View Source
const (
	FlagFile = 1 << iota
)

flag list

Variables

This section is empty.

Functions

func Error

func Error(args ...interface{})

Error logs to ERROR log.

func Errorf

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

Error logs to ERROR log.

func Fatal

func Fatal(args ...interface{})

Fatal logs to ERROR log. with os.Exit(1).

func Fatalf

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

Fatal logs to ERROR log. with os.Exit(1).

func Info

func Info(args ...interface{})

Info logs to INFO log.

func Infof

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

Info logs to INFO log.

func Warning

func Warning(args ...interface{})

Warning logs to WARNING log.

func Warningf

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

Warning logs to WARNING log.

Types

type Entry

type Entry struct {
	Level   Level
	Time    time.Time
	Data    map[string]interface{}
	Message string
	// contains filtered or unexported fields
}

Entry log entry

func NewEntry

func NewEntry(log *Logging) *Entry

func WithContext

func WithContext(ctx context.Context) *Entry

WithContext context

func WithData

func WithData(data map[string]interface{}) *Entry

WithData custom data

func (*Entry) Error

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

Error logs to ERROR log.

func (*Entry) Errorf

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

Error logs to ERROR log.

func (*Entry) Fatal

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

Fatal logs to ERROR log. with os.Exit(1).

func (*Entry) Fatalf

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

Fatal logs to ERROR log. with os.Exit(1).

func (*Entry) Info

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

Info logs to INFO log.

func (*Entry) Infof

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

Info logs to INFO log.

func (*Entry) Output

func (e *Entry) Output(calldepth int)

Output print log

func (*Entry) Warning

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

Warning logs to WARNING log.

func (*Entry) Warningf

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

Warning logs to WARNING log.

func (*Entry) WithContext

func (e *Entry) WithContext(ctx context.Context) *Entry

WithContext context

func (*Entry) WithData

func (e *Entry) WithData(data map[string]interface{}) *Entry

WithData custom data

type Level

type Level int

Level logger level

const (
	LevelInfo Level = iota
	LevelWarning
	LevelError
	LevelFatal
)

list log level

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	// Info logs to INFO log.
	Info(args ...interface{})
	// Info logs to INFO log.
	Infof(format string, args ...interface{})
	// Warning logs to WARNING log.
	Warning(args ...interface{})
	// Warning logs to WARNING log.
	Warningf(format string, args ...interface{})
	// Error logs to ERROR log.
	Error(args ...interface{})
	// Error logs to ERROR log.
	Errorf(format string, args ...interface{})
	// Fatal logs to ERROR log. with os.Exit(1).
	Fatal(args ...interface{})
	// Fatal logs to ERROR log. with os.Exit(1).
	Fatalf(format string, args ...interface{})
	// V reports whether verbosity level log is at least the requested verbose level.
	V(level Level) bool
}

Logger represents a logger.

type Logging

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

Logging logging setup.

func NewLogging

func NewLogging(opts ...Option) *Logging

NewLogger log logger

func (*Logging) Error

func (log *Logging) Error(args ...interface{})

Error logs to ERROR log.

func (*Logging) Errorf

func (log *Logging) Errorf(format string, args ...interface{})

Error logs to ERROR log.

func (*Logging) Fatal

func (log *Logging) Fatal(args ...interface{})

Fatal logs to ERROR log. with os.Exit(1).

func (*Logging) Fatalf

func (log *Logging) Fatalf(format string, args ...interface{})

Fatal logs to ERROR log. with os.Exit(1).

func (*Logging) Info

func (log *Logging) Info(args ...interface{})

Info logs to INFO log.

func (*Logging) Infof

func (log *Logging) Infof(format string, args ...interface{})

Info logs to INFO log.

func (*Logging) V

func (log *Logging) V(l Level) bool

V reports whether verbosity level log is at least the requested verbose level.

func (*Logging) Warning

func (log *Logging) Warning(args ...interface{})

Warning logs to WARNING log.

func (*Logging) Warningf

func (log *Logging) Warningf(format string, args ...interface{})

Warning logs to WARNING log.

type Option

type Option func(opts *Options)

Option logger option

func WithFlag

func WithFlag(flag int) Option

WithFlag options flag

func WithLevel

func WithLevel(l Level) Option

WithLevel set severity level

func WithService

func WithService(s string) Option

WithService set service name

func WithWriter

func WithWriter(w io.Writer) Option

WithWriter log output

type Options

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

Options logger options

Jump to

Keyboard shortcuts

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