logging

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 9 Imported by: 32

README

logging Build Status Coverage Status

Example Code:

package main

import "github.com/tosone/logging"

type Test struct {
	String string
	Int    int
}

func main() {
	var test = Test{String: "123123123", Int: 1}
	logging.Info("info level")
	logging.WithFields(logging.Fields{"field1": 1, "field2": "123"}).Info("info level")
	logging.Warn("warn info")
	logging.WithFields(logging.Fields{"field1": 1, "field2": "123"}).Warn("warn level")
	logging.Debug(test)
	logging.Debugf("%+v", test)
}

OutPut:

INFO[10:39:49.100] info level                                file=main.go line=12
INFO[10:39:49.101] info level                                file=main.go line=13 field1=1 field2=123
WARN[10:39:49.101] warn info                                 file=main.go line=14
WARN[10:39:49.101] warn level                                file=main.go line=15 field1=1 field2=123
DEBU[10:39:49.101] {123123123 1}                             file=main.go line=16
DEBU[10:39:49.101] {String:123123123, Int:1}                 file=main.go line=17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(str ...interface{})

Debug ..

func Debugf

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

Debugf ..

func Error

func Error(str ...interface{})

Error ..

func Errorf

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

Errorf ..

func Fatal

func Fatal(str ...interface{})

Fatal ..

func Fatalf

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

Fatalf ..

func Info

func Info(str ...interface{})

Info ..

func Infof

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

Infof ..

func Panic

func Panic(str ...interface{})

Panic ..

func Panicf

func Panicf(format string, str ...interface{})

func Rotate

func Rotate() (err error)

Rotate rotate the output log file

func Setting

func Setting(conf Config)

Setting set the logger output method

func Warn

func Warn(str ...interface{})

Warn ..

func Warnf

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

Warnf ..

func Warningf added in v1.2.0

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

Warningf ..

Types

type Config

type Config struct {
	LogLevel   Level
	Filename   string
	MaxSize    int
	MaxBackups int
	MaxAge     int
	LocalTime  bool
	Compress   bool
}

type Entry

type Entry interface {
	Panic(...interface{})
	Panicf(string, ...interface{})
	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Error(...interface{})
	Errorf(string, ...interface{})
	Warn(...interface{})
	Warnf(string, ...interface{})
	Warningf(string, ...interface{})
	Info(...interface{})
	Infof(string, ...interface{})
	Debug(...interface{})
	Debugf(string, ...interface{})
	// contains filtered or unexported methods
}

Entry ..

func WithFields

func WithFields(fields Fields) (entry Entry)

WithFields add more field

type Fields

type Fields map[string]interface{}

Fields ..

type Inst added in v1.2.0

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

inst ..

func (*Inst) Debug added in v1.2.0

func (i *Inst) Debug(str ...interface{})

Debug ..

func (*Inst) Debugf added in v1.2.0

func (i *Inst) Debugf(format string, str ...interface{})

Debugf ..

func (*Inst) Error added in v1.2.0

func (i *Inst) Error(str ...interface{})

Error ..

func (*Inst) Errorf added in v1.2.0

func (i *Inst) Errorf(format string, str ...interface{})

Errorf ..

func (*Inst) Fatal added in v1.2.0

func (i *Inst) Fatal(str ...interface{})

Fatal ..

func (*Inst) Fatalf added in v1.2.0

func (i *Inst) Fatalf(format string, str ...interface{})

Fatalf ..

func (*Inst) Info added in v1.2.0

func (i *Inst) Info(str ...interface{})

Info ..

func (*Inst) Infof added in v1.2.0

func (i *Inst) Infof(format string, str ...interface{})

Info ..

func (*Inst) Panic added in v1.2.0

func (i *Inst) Panic(str ...interface{})

Panic ..

func (*Inst) Panicf added in v1.2.0

func (i *Inst) Panicf(format string, str ...interface{})

Panicf ..

func (*Inst) Warn added in v1.2.0

func (i *Inst) Warn(str ...interface{})

Warn ..

func (*Inst) Warnf added in v1.2.0

func (i *Inst) Warnf(format string, str ...interface{})

Warnf ..

func (*Inst) Warningf added in v1.2.0

func (i *Inst) Warningf(format string, str ...interface{})

type Level

type Level uint

Level log level

const (
	// DebugLevel Debug level
	DebugLevel Level = iota
	// InfoLevel Info level
	InfoLevel
	// WarnLevel Warn Level
	WarnLevel
	// ErrorLevel Error Level
	ErrorLevel
	// FatalLevel Fatal level
	FatalLevel
	// PanicLevel Panic level
	PanicLevel
)

func (Level) String

func (level Level) String() string

String get the log level's string

Jump to

Keyboard shortcuts

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