logga

package module
v0.0.0-...-3639573 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: Apache-2.0 Imports: 7 Imported by: 1

README

Logga - simple, "convention over configuration" logger for golang

Installation

go get "github.com/Komly/logga"

Usage

logga := logga.NewLogger(
    logga.WithLevel(logga.Error),
    logga.WithMessageTemplate("{{.Level}} - {{.Time}} -  {{.Message}}\n"),
)
logga.Debugf("Debug message: %d", 1)
logga.Infof("Info message: %d", 2)
logga.Warningf("Warning message: %d", 3)
logga.Errorf("Error message: %d", 4)
logga.Fatalf("Fatal message: %d", 5)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	Format(message *LogRecord, out io.Writer)
}

type JSONFormatter

type JSONFormatter struct {
}

func (JSONFormatter) Format

func (j JSONFormatter) Format(message *LogRecord, out io.Writer)

type Level

type Level int
const (
	All Level = iota
	Debug
	Info
	Warning
	Error
	Fatal
	Off
)

type LogRecord

type LogRecord struct {
	Message string `json:"message"`
	Time    string `json:"time"`
	Level   string `json:"level"`
}

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
	SetOption(Option)
}

func NewLogger

func NewLogger(opts ...Option) Logger

type Option

type Option func(Logger) error

func WithFormatter

func WithFormatter(fmt Formatter) Option

func WithLevel

func WithLevel(level Level) Option

func WithMessageTemplate

func WithMessageTemplate(tmplText string) Option

func WithOutput

func WithOutput(out io.Writer) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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