logger

package
v0.0.0-...-5d03f69 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

These flags define which text to prefix to each log entry generated by the Logger. Bits are or'ed together to control what's printed. There is no control over the order they appear (the order listed here) or the format they present (as described in the comments). The prefix is followed by a colon only when Llongfile or Lshortfile is specified. For example, flags Ldate | Ltime (or LstdFlags) produce,

2009/01/23 01:23:23 message

while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,

2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message

Variables

This section is empty.

Functions

func Black

func Black(message string) string

Black returns a black string

func BlackBold

func BlackBold(message string) string

BlackBold returns a black Bold string

func Blue

func Blue(message string) string

Blue returns a blue string

func BlueBold

func BlueBold(message string) string

BlueBold returns a blue Bold string

func Bold

func Bold(message string) string

Bold returns a Bold string

func Cyan

func Cyan(message string) string

Cyan returns a cyan string

func CyanBold

func CyanBold(message string) string

CyanBold returns a cyan Bold string

func Gray

func Gray(message string) string

Gray returns a gray string

func GrayBold

func GrayBold(message string) string

GrayBold returns a gray Bold string

func Green

func Green(message string) string

Green returns a green string

func GreenBold

func GreenBold(message string) string

GreenBold returns a green Bold string

func Magenta

func Magenta(message string) string

Magenta returns a magenta string

func MagentaBold

func MagentaBold(message string) string

MagentaBold returns a magenta Bold string

func NewLevelWriter

func NewLevelWriter(l LEVEL) io.Writer

NewLevelWriter defined return a level writer

func NewRotateWriter

func NewRotateWriter(dirName string, maxSize int64, flag int, perm os.FileMode) io.Writer

NewRotateWriter defined return a rotate writer

func Red

func Red(message string) string

Red returns a red string

func RedBold

func RedBold(message string) string

RedBold returns a red Bold string

func White

func White(message string) string

White returns a white string

func WhiteBold

func WhiteBold(message string) string

WhiteBold returns a white Bold string

func Yellow

func Yellow(message string) string

Yellow returns a yellow string

func YellowBold

func YellowBold(message string) string

YellowBold returns a yellow Bold string

Types

type FormatFunc

type FormatFunc func(map[string]string) string

FormatFunc log format

type Journal

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

Journal logger

func CreateLogger

func CreateLogger(level LEVEL, format FormatFunc, transports []*Transport) *Journal

CreateLogger logger

func (*Journal) AddTransports

func (j *Journal) AddTransports(transports ...*Transport) *Journal

AddTransports defined append transports

func (*Journal) Debug

func (j *Journal) Debug(format string, a ...interface{})

Debug level

func (*Journal) Error

func (j *Journal) Error(format string, a ...interface{})

Error level

func (*Journal) Info

func (j *Journal) Info(format string, a ...interface{})

Info level

func (*Journal) Init

func (j *Journal) Init(init func(*Journal)) *Journal

Init Journal

func (*Journal) SetFlags

func (j *Journal) SetFlags(flag int)

SetFlags sets the output flags for the logger.

func (*Journal) Silly

func (j *Journal) Silly(format string, a ...interface{})

Silly level

func (*Journal) Verbose

func (j *Journal) Verbose(format string, a ...interface{})

Verbose level

func (*Journal) Warn

func (j *Journal) Warn(format string, a ...interface{})

Warn level

type LEVEL

type LEVEL int

LEVEL level tags

const (
	// Maxsize file size
	Maxsize = 1024 * 1024 * 10
	// ERROR level
	ERROR LEVEL = iota + 1
	// WARN level
	WARN
	// INFO level
	INFO
	// VERBOSE level
	VERBOSE
	// DEBUG level
	DEBUG
	// SILLY level
	SILLY
)

type LevelWriter

type LevelWriter struct {
	W     io.Writer
	Level LEVEL
}

LevelWriter defined level writer

func (*LevelWriter) Write

func (c *LevelWriter) Write(p []byte) (int, error)

type MutiWriter

type MutiWriter struct {
	Level LEVEL
	// contains filtered or unexported fields
}

MutiWriter write with level

func (*MutiWriter) Write

func (t *MutiWriter) Write(p []byte) (n int, err error)

type RotateWriter

type RotateWriter struct {
	Dirname string
	MaxSize int64
	// contains filtered or unexported fields
}

RotateWriter rotate file

func (*RotateWriter) Write

func (r *RotateWriter) Write(p []byte) (n int, err error)

type Transport

type Transport struct {
	Dirname string
	Level   LEVEL
	Maxsize int64
	Writer  io.Writer
}

Transport for Journal

func NewFileTransport

func NewFileTransport(t Transport) *Transport

NewFileTransport defined FileTransport

func NewPrintTransport

func NewPrintTransport(t Transport) *Transport

NewPrintTransport defined PrintTransport

Jump to

Keyboard shortcuts

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