log

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT, Apache-2.0 Imports: 5 Imported by: 4

README

Log

This is the global logger for all micro based libraries which makes use of github.com/go-log/log.

It defaults the logger to the stdlib log implementation.

Set Logger

Set the logger for micro libraries

// import go-micro/util/log
import "git.xswitch.cn/xswitch/xctrl/stack/util/log"

// SetLogger expects github.com/go-log/log.Logger interface
log.SetLogger(mylogger)

Documentation

Overview

Package log is a global internal logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug provides debug level logging

func Debugf

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

Debugf provides debug level logging

func Error

func Error(v ...interface{})

Error provides warn level logging

func Errorf

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

Errorf provides warn level logging

func Fatal

func Fatal(v ...interface{})

Fatal logs with Log and then exits with os.Exit(1)

func Fatalf

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

Fatalf logs with Logf and then exits with os.Exit(1)

func Info

func Info(v ...interface{})

Info provides info level logging

func Infof

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

Infof provides info level logging

func Log

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

Log inspired from github.com/go-log/log.Log

func Logf

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

func Name

func Name(name string)

Set service name

func SetLevel

func SetLevel(l Level)

SetLevel sets the log level

func SetLogger

func SetLogger(l Logger)

SetLogger sets the local logger

func SetPrefix

func SetPrefix(p string)

Set a prefix for the logger

func Trace

func Trace(v ...interface{})

Trace provides trace level logging

func Tracef

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

Tracef provides trace level logging

func Warn

func Warn(v ...interface{})

Warn provides warn level logging

func Warnf

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

Warnf provides warn level logging

func WithLevel

func WithLevel(l Level, v ...interface{})

WithLevel logs with the level specified

func WithLevelf

func WithLevelf(l Level, format string, v ...interface{})

WithLevel logs with the level specified

Types

type Level

type Level int

level is a log level

const (
	LevelFatal Level = iota
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
	LevelTrace
)

func GetLevel

func GetLevel() Level

GetLevel returns the current level

type LogLogger

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

func New

func New() *LogLogger

func (*LogLogger) Log

func (logger *LogLogger) Log(level int, v ...interface{})

func (*LogLogger) Logf

func (logger *LogLogger) Logf(level int, format string, v ...interface{})

type Logger

type Logger interface {
	// Log inserts a log entry.  Arguments may be handled in the manner
	// of fmt.Print, but the underlying logger may also decide to handle
	// them differently.
	Log(level int, v ...interface{})
	// Logf insets a log entry.  Arguments are handled in the manner of
	// fmt.Printf.
	Logf(level int, format string, v ...interface{})
}

Logger is a generic logging interface

func GetLogger

func GetLogger() Logger

GetLogger returns the local logger

type LoggerStruct

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

func NewLog

func NewLog(out io.Writer, prefix string, flag int) *LoggerStruct

Jump to

Keyboard shortcuts

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