logger

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 3 Imported by: 9

README

NAME

logger - A simple logging library for Go

DESCRIPTION

logger is a simple logging library for go. It extends the log package and also provides 'verbose' and 'debug' messages support. To use:

import "github.com/marcopaganini/logger"

log *logger.Logger
log = logger.New("prefix")
log.SetVerboseLevel(1)
log.SetDebugLevel(2)

// All the usual log.* functions can be used normally, plus
log.Verboseln(1, "This prints only if verbose level >= 1")
log.Debugln(2, "This prints only if debug level >= 2")

// log.Verbosef and logDebugf are also available

AUTHOR

(C) Aug/2014 by Marco Paganini

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger represents a logger object

func New

func New(prefix string) *Logger

New Creates a new Logger instance.

func (*Logger) Debugf

func (o *Logger) Debugf(level int, format string, v ...interface{})

Debugf uses the formatting string and variables to print a message to the output streams if the current debugging level is greater than or equal to the specified debugging level.

func (*Logger) Debugln

func (o *Logger) Debugln(level int, v ...interface{})

Debugln prints the message to the output streams, followed by a newline, if the current debugging level is greater than or equal the specified debugging level.

func (*Logger) Fatal

func (o *Logger) Fatal(v ...interface{})

Fatal is a convenience alias for Fatalln.

func (*Logger) Fatalf

func (o *Logger) Fatalf(format string, v ...interface{})

Fatalf prints a formatted message to the output streams and calls os.Exit(1).

func (*Logger) Fatalln

func (o *Logger) Fatalln(v ...interface{})

Fatalln prints the message to the output streams followed by a newline and calls os.Exit(1).

func (*Logger) Printf

func (o *Logger) Printf(format string, v ...interface{})

Printf uses the formatting string and variables to print a message to the output streams.

func (*Logger) Println

func (o *Logger) Println(v ...interface{})

Println prints the message to the output streams followed by a newline.

func (*Logger) SetDebugLevel

func (o *Logger) SetDebugLevel(n int)

SetDebugLevel sets the debugging level for this log instance.

func (*Logger) SetMirrorOutput

func (o *Logger) SetMirrorOutput(output io.Writer)

SetMirrorOutput sets the mirror output stream to the writers.

func (*Logger) SetOutputs

func (o *Logger) SetOutputs(outputs []io.Writer)

SetOutputs sets all logging outputs to the outputs presented in the slice of io.Writers.

func (*Logger) SetVerboseLevel

func (o *Logger) SetVerboseLevel(n int)

SetVerboseLevel sets the verbosity level for this log instance.

func (*Logger) Verbosef

func (o *Logger) Verbosef(level int, format string, v ...interface{})

Verbosef uses the formatting string and variables to print a message to the output streams if the current verbose level is greater than or equal to the specified verbose level.

func (*Logger) Verboseln

func (o *Logger) Verboseln(level int, v ...interface{})

Verboseln prints the message to the output streams, followed by a newline, if the current verbose level is greater than or equal the specified verbosity level.

Jump to

Keyboard shortcuts

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