levellogger

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: MIT Imports: 1 Imported by: 38

README

Go Report Card GoDoc

Level Logger

A three level logger for Golang. It has the following levels: debug, info, and error.

The logging level can be set by setting the LogLevel varible as shown:

Error

Error logging is alwas on and cannot be turned off.

    var l Logger
	i, e := strconv.Atoi("1q")
	l.Error(e)

Output
2020/02/02 15:57:51 ERROR:  strconv.Atoi: parsing "1q": invalid syntax

Info
    var l Logger
	l.LogLevel = InfoLevel
	i, e := strconv.Atoi("1q")
	l.Info(e)

Output
2020/02/02 15:57:51 INFO:  strconv.Atoi: parsing "1q": invalid syntax

Debug
    var l Logger
	l.LogLevel = DebugLevel
	i, e := strconv.Atoi("1q")
	l.Debug(e)
	
Output
2020/02/02 15:57:51 DEBUG:  strconv.Atoi: parsing "1q": invalid syntax

Log All
    var l Logger
	l.LogLevel = AllLevel
	i, e := strconv.Atoi("1q")
	l.Info(e)
	
Output
2020/02/02 15:57:51 INFO:  strconv.Atoi: parsing "1q": invalid syntax

Logging Off
    var l Logger
	l.LogLevel = OffLevel
	i, e := strconv.Atoi("1q")
	l.Info(e)
	
Output
No logs are shown

Documentation

Index

Constants

View Source
const (
	//OffLevel OffLevel
	OffLevel = 0
	//InfoLevel InfoLevel
	InfoLevel = 1
	//DebugLevel DebugLevel
	DebugLevel = 2
	//AllLevel AllLevel
	AllLevel = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	LogLevel int
}

Logger Logger

func (*Logger) Debug

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

Debug Debug

func (*Logger) Error

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

Error Error

func (*Logger) Info

func (l *Logger) Info(val ...interface{})

Info Info

Jump to

Keyboard shortcuts

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