spoor

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 13 Imported by: 0

README ¶

spoor

make logger switchable and adapted project

💡 Usage

You can import spoor using:

import (
    "github.com/LingARISTOTLE/spoor"
)

Then use one of the helpers below:

fileWriter

fileWriter := spoor.NewFileWriter("log", 0, 0, 0)
l := spoor.NewSpoor(spoor.DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, spoor.WithFileWriter(fileWriter))
l.DebugF("hhhh")
select {}

consoleWriter

l := NewSpoor(DEBUG, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Llongfile, WithNormalWriter(os.Stdout))
l.DebugF("hhhh")

elasticWriter



clickHouseWriter



logbusWriter



Documentation ¶

Index ¶

Constants ¶

View Source
const (
	DEBUG = Level(1)
	INFO  = Level(2)
	WARN  = Level(3)
	ERROR = Level(4)
	FATAL = Level(5)
)

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type AppLogFunc ¶

type AppLogFunc func(lvl Level, f string, args ...interface{})

type FileWriter ¶

type FileWriter struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func NewFileWriter ¶

func NewFileWriter(logDir string, bufferSize, flushInterval int, maxSize uint64) *FileWriter

func (*FileWriter) Sync ¶

func (fw *FileWriter) Sync() error

func (*FileWriter) Write ¶

func (fw *FileWriter) Write(p []byte) (n int, err error)

type Level ¶

type Level int

func ParseLogLevel ¶

func ParseLogLevel(levelStr string) (Level, error)

func (*Level) Get ¶

func (l *Level) Get() interface{}

func (*Level) Set ¶

func (l *Level) Set(s string) error

func (Level) String ¶

func (l Level) String() string

type Logger ¶

type Logger interface {
	Output(callerSkip int, s string) error
	SetOutput(w io.Writer)
}

type LoggingSetting ¶

type LoggingSetting struct {
	Dir          string
	Level        int
	Prefix       string
	WriterOption Option
}

type NilLogger ¶

type NilLogger struct{}

func (NilLogger) Output ¶

func (l NilLogger) Output(callerSkip int, s string) error

func (*NilLogger) SetOutput ¶

func (l *NilLogger) SetOutput(writer io.Writer)

type Option ¶

type Option func(spoor *Spoor)

func WithConsoleWriter ¶

func WithConsoleWriter(writer io.Writer) Option

func WithFileWriter ¶

func WithFileWriter(writer *FileWriter) Option

type Spoor ¶

type Spoor struct {
	Logger
	// contains filtered or unexported fields
}

func NewSpoor ¶

func NewSpoor(cfgLevel Level, prefix string, flag int, opts ...Option) *Spoor

func (*Spoor) CheckLevel ¶

func (l *Spoor) CheckLevel(level Level) bool

Jump to

Keyboard shortcuts

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