logger

package
v1.4.19 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger provides functions to log on different levels/severities. Levels have a canonical ordering and there is support silencing log statements with levels below a given threshold.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug logging.

Example

Log on "debug" level.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	logger.Debug("debug message")
}
Output:

func Error added in v1.4.8

func Error(v ...interface{})

Error logging in red.

Example

Log on "error" level.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	logger.Error("an error occurred")
}
Output:

func Info

func Info(v ...interface{})

Info logging.

Example

Log on "info" level.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	logger.Info("informational message")
}
Output:

func Success

func Success(v ...interface{})

Success logging in green.

Example

Log on "success" level.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	logger.Success("successfully reached a milestone in my program flow")
}
Output:

func Warn

func Warn(v ...interface{})

Warn logging in yellow.

Example

Log on "warn" level.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	logger.Warn("a warning")
}
Output:

Types

type Level added in v1.4.17

type Level struct {
}

Level represents a Value for different logging configs.

Example

Level can be used with the flag package.

package main

import (
	"flag"

	"github.com/bpicode/fritzctl/logger"
)

func main() {
	l := logger.Level{}
	flag.Var(&l, "log", "logging verbosity, e.g. 'info'")
	flag.Parse()
}
Output:

func (*Level) Set added in v1.4.17

func (l *Level) Set(val string) error

Set configures the loglevel for the application.

Example

Logging can be turned off manually.

package main

import (
	"github.com/bpicode/fritzctl/logger"
)

func main() {
	l := &logger.Level{}
	l.Set("none")
	logger.Warn("log statement")
}
Output:

func (*Level) String added in v1.4.17

func (l *Level) String() string

String represents the default value.

func (*Level) Type added in v1.4.17

func (l *Level) Type() string

Type returns a name for the value type.

Jump to

Keyboard shortcuts

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