redlog

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 12 Imported by: 18 modules, 26 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Redlog

Build Status GoDoc

Redlog is a Redis style logger for Go.

Installing

go get -u github.com/tidwall/redlog

Example

log := redlog.New(os.Stderr)
log.Printf("Server started at 10.0.1.5:6379")
log.Debugf("Connected to leader")
log.Warningf("Heartbeat timeout reached, starting election")

Output:

93324:M 29 Aug 09:30:59.943 * Server started at 10.0.1.5:6379
93324:M 29 Aug 09:31:01.892 . Connected to leader
93324:M 29 Aug 09:31:02.331 # Heartbeat timeout reached, starting election 

Contact

Josh Baker @tidwall

License

Redcon source code is available under the MIT License.

Documentation

Overview

Package redlog provides a Redis compatible logger.

http://build47.com/redis-log-format-levels/

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	Level:      2,
	Filter:     nil,
	PostFilter: nil,
	App:        'M',
	TimeFormat: "02 Jan 2006 15:04:05.000",
}

DefaultOptions ...

View Source
var HashicorpRaftFilter func(line string, tty bool) (msg string, app byte,
	level int)

HashicorpRaftFilter is used as a filter to convert a log message from the hashicorp/raft package into redlog structured message.

Functions

func RedisLogColorizer

func RedisLogColorizer(wr io.Writer) io.Writer

RedisLogColorizer filters the Redis log output and colorizes it.

Types

type Logger

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

Logger ...

func New

func New(wr io.Writer, opts *Options) *Logger

New sets the level of the logger.

0 - Debug
1 - Verbose
2 - Notice
3 - Warning

func (*Logger) App added in v1.1.0

func (l *Logger) App() byte

App returns the app character

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug ...

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf ...

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln ...

func (*Logger) Error added in v1.2.1

func (l *Logger) Error(args ...interface{})

Error ...

func (*Logger) Errorf added in v1.2.1

func (l *Logger) Errorf(format string, args ...interface{})

Errorf ...

func (*Logger) Errorln added in v1.2.1

func (l *Logger) Errorln(args ...interface{})

Errorln ...

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal ...

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf ...

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln ...

func (*Logger) GoLogger

func (l *Logger) GoLogger() *log.Logger

GoLogger returns a standard Go log.Logger which when used, will print in the Redlog format.

func (*Logger) Notice

func (l *Logger) Notice(args ...interface{})

Notice ...

func (*Logger) Noticef

func (l *Logger) Noticef(format string, args ...interface{})

Noticef ...

func (*Logger) Noticeln

func (l *Logger) Noticeln(args ...interface{})

Noticeln ...

func (*Logger) Panic added in v1.0.0

func (l *Logger) Panic(args ...interface{})

Panic ...

func (*Logger) Panicf added in v1.0.0

func (l *Logger) Panicf(format string, args ...interface{})

Panicf ...

func (*Logger) Panicln added in v1.0.0

func (l *Logger) Panicln(args ...interface{})

Panicln ...

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print ...

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf ...

func (*Logger) Println

func (l *Logger) Println(args ...interface{})

Println ...

func (*Logger) SetApp added in v1.1.0

func (l *Logger) SetApp(app byte)

SetApp sets the app character

func (*Logger) Verb added in v1.0.0

func (l *Logger) Verb(args ...interface{})

Verb ...

func (*Logger) Verbf added in v1.0.0

func (l *Logger) Verbf(format string, args ...interface{})

Verbf ...

func (*Logger) Verbln added in v1.0.0

func (l *Logger) Verbln(args ...interface{})

Verbln ...

func (*Logger) Warning

func (l *Logger) Warning(args ...interface{})

Warning ...

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

Warningf ...

func (*Logger) Warningln

func (l *Logger) Warningln(args ...interface{})

Warningln ...

func (*Logger) Write

func (l *Logger) Write(p []byte) (int, error)

Write writes to the log

type Options added in v1.0.0

type Options struct {
	Level      int
	Filter     func(line string, tty bool) (msg string, app byte, level int)
	PostFilter func(line string, tty bool) string
	TimeFormat string
	App        byte
}

Options ...

Jump to

Keyboard shortcuts

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