log

package module
v0.0.0-...-88ce1b2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 6 Imported by: 6

README

GoDoc Go Report Card License

log

Log package with levels and color for Go

Example

package main
  
import (
        "flag"

        "github.com/mickep76/log"
)

func main() {
        lvlArg := flag.String("lvl", "debug", "Log level [debug|info|warn|err|crit].")
        flag.Parse()

        lvl, err := log.ToLevel(*lvlArg)
        if err != nil {
                log.Fatal(err)
        }
        log.SetLevel(lvl)

        log.Debug("debug level")
        log.Info("info level")
        log.Warn("warn level")
        log.Error("error level")
        log.Fatal("critical level")
}

Documentation

Index

Constants

View Source
const (
	LevelNone = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelCrit
)

Level constants.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug log message.

func Debugf

func Debugf(f string, v ...interface{})

Debugf log message with formatting.

func Debugln

func Debugln(v ...interface{})

Debugln log message with newline.

func Error

func Error(v ...interface{})

Error log message.

func Errorf

func Errorf(f string, v ...interface{})

Errorf log message with formatting.

func Errorln

func Errorln(v ...interface{})

Errorln log message with newline.

func Fatal

func Fatal(v ...interface{})

Fatal log message and exit with status 1.

func Fatalf

func Fatalf(f string, v ...interface{})

Fatalf log message with formmating and exit with status 1.

func Fatalln

func Fatalln(v ...interface{})

Fatalln log message with newline and exit with status 1.

func Info

func Info(v ...interface{})

Info log message.

func Infof

func Infof(f string, v ...interface{})

Infof log message with formatting.

func Infoln

func Infoln(v ...interface{})

Infoln log message with newline.

func Print

func Print(v ...interface{})

Print log message.

func Printf

func Printf(f string, v ...interface{})

Printf log message with formatting.

func Println

func Println(v ...interface{})

Println log message with newline.

func SetFlags

func SetFlags(flag int)

SetFlags for log.

func SetLevel

func SetLevel(l Level)

SetLevel set log level.

func SetMultiOutput

func SetMultiOutput(writers ...io.Writer)

SetMultiOutput set multiple outputs.

func SetNoColor

func SetNoColor()

SetNoColor for logs.

func SetOutput

func SetOutput(w io.Writer)

SetOutput set output.

func Warn

func Warn(v ...interface{})

Warn log message.

func Warnf

func Warnf(f string, v ...interface{})

Warnf log message with formatting.

func Warnln

func Warnln(v ...interface{})

Warnln log message with newline.

Types

type Level

type Level int

Level type.

func GetLevel

func GetLevel() Level

GetLevel get log level.

func ToLevel

func ToLevel(s string) (Level, error)

ToLevel get level from a string.

func (Level) String

func (l Level) String() string

String level to string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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