go-micro: github.com/micro/go-micro/logger Index | Files

package logger

import "github.com/micro/go-micro/logger"

Package log provides a log interface

Index

Package Files

context.go default.go level.go logger.go options.go

func Debug Uses

func Debug(args ...interface{})

func Debugf Uses

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

func Error Uses

func Error(args ...interface{})

func Errorf Uses

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

func Fatal Uses

func Fatal(args ...interface{})

func Fatalf Uses

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

func Info Uses

func Info(args ...interface{})

func Infof Uses

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

func Init Uses

func Init(opts ...Option) error

func Log Uses

func Log(level Level, v ...interface{})

func Logf Uses

func Logf(level Level, format string, v ...interface{})

func NewContext Uses

func NewContext(ctx context.Context, l Logger) context.Context

func String Uses

func String() string

func Trace Uses

func Trace(args ...interface{})

func Tracef Uses

func Tracef(template string, args ...interface{})

func Warn Uses

func Warn(args ...interface{})

func Warnf Uses

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

type Level Uses

type Level int8
const (
    // TraceLevel level. Designates finer-grained informational events than the Debug.
    TraceLevel Level = iota - 2
    // DebugLevel level. Usually only enabled when debugging. Very verbose logging.
    DebugLevel
    // InfoLevel is the default logging priority.
    // General operational entries about what's going on inside the application.
    InfoLevel
    // WarnLevel level. Non-critical entries that deserve eyes.
    WarnLevel
    // ErrorLevel level. Logs. Used for errors that should definitely be noted.
    ErrorLevel
    // PanicLevel level, logs the message and then panics.
    PanicLevel
    // FatalLevel level. Logs and then calls `logger.Exit(1)`. highest level of severity.
    FatalLevel
)

func GetLevel Uses

func GetLevel(levelStr string) (Level, error)

GetLevel converts a level string into a logger Level value. returns an error if the input string does not match known values.

func (Level) Enabled Uses

func (l Level) Enabled(lvl Level) bool

Enabled returns true if the given level is at or above this level.

func (Level) String Uses

func (l Level) String() string

type Logger Uses

type Logger interface {
    // Init initialises options
    Init(options ...Option) error
    // The Logger options
    Options() Options
    // Error set `error` field to be logged
    Error(err error) Logger
    // Fields set fields to always be logged
    Fields(fields map[string]interface{}) Logger
    // Log writes a log entry
    Log(level Level, v ...interface{})
    // Logf writes a formatted log entry
    Logf(level Level, format string, v ...interface{})
    // String returns the name of logger
    String() string
}

Logger is a generic logging interface

var (
    // Default logger
    DefaultLogger Logger = NewLogger()
)

func Fields Uses

func Fields(fields map[string]interface{}) Logger

func FromContext Uses

func FromContext(ctx context.Context) (Logger, bool)

func NewLogger Uses

func NewLogger(opts ...Option) Logger

NewLogger builds a new logger based on options

func WithError Uses

func WithError(err error) Logger

type Option Uses

type Option func(*Options)

func SetOption Uses

func SetOption(k, v interface{}) Option

func WithFields Uses

func WithFields(fields map[string]interface{}) Option

WithFields set default fields for the logger

func WithLevel Uses

func WithLevel(level Level) Option

WithLevel set default level for the logger

func WithOutput Uses

func WithOutput(out io.Writer) Option

WithOutput set default output writer for the logger

type Options Uses

type Options struct {
    // The logging level the logger should log at. default is `InfoLevel`
    Level Level
    // fields to always be logged
    Fields map[string]interface{}
    // It's common to set this to a file, or leave it default which is `os.Stderr`
    Out io.Writer
    // Alternative options
    Context context.Context
}

Package logger imports 6 packages (graph). Updated 2020-02-22. Refresh now. Tools for package owners.