loglvl

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

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

Go to latest
Published: Apr 30, 2017 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Overview

Package loglvl adds a bit of leveled logging to log.Logger.

Example
var buf bytes.Buffer
log := New(0, log.New(&buf, "", log.LstdFlags))

msg0 := "a level 0 message"
if log.Level() >= 0 {
	log.Println(msg0)
}

msg1 := "a level 1 message"
if log.Level() >= 1 {
	log.Println(msg1)
}

msgs := string(buf.Bytes())
fmt.Println(strings.Contains(msgs, msg0))
fmt.Println(strings.Contains(msgs, msg1))
Output:

true
false

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger wraps a log.Logger so as to include a level.

func New

func New(level int, log *log.Logger) Logger

New returns a new Logger with the given level and underlying log.Logger.

func (Logger) Level

func (log Logger) Level() int

Level returns log's level.

Jump to

Keyboard shortcuts

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