log

package
v0.0.0-...-c2cee1d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//LevelDebug debug level logging, all messages outputted
	LevelDebug = "DEBUG"
	//LevelInfo info level logging, no debug information, a lot of info
	LevelInfo = "INFO"
	//LevelWarn warning level logging, only recovered errors, and fatal errors
	LevelWarn = "WARN"
	//LevelError error level logging, no other information other then fatal errors
	LevelError = "ERROR"
)

Variables

View Source
var DefaultOptions = Options{
	Path:        "",
	Level:       "DEBUG",
	Usage:       true,
	BlurTimes:   1,
	ShowAddress: true,
}

DefaultOptions holds the default options for LoggingOptions objects

View Source
var ErrOptionLevel = errors.New("invalid logging level option provided")

ErrOptionLevel specifies the level field of the LoggingOptions object is invalid

Functions

func Debug

func Debug(args ...interface{})

Debug logs a debug message

func Debugf

func Debugf(str string, args ...interface{})

Debugf logs a debug message using formatting like fmt.Printf

func Err

func Err(msg string, args ...interface{})

Err logs an error message from an error object. Uses fmt.Printf for the bulk work, uses the last argument as the error object. Example:

err := someMethod()
log.Err("failed on id '%s'", 123, err)

func Error

func Error(args ...interface{})

Error logs an error message

func Errorf

func Errorf(str string, args ...interface{})

Errorf logs an error message using formatting like fmt.Printf

func Get

func Get() *logrus.Logger

Get returns the underlying logrus logger object

func Info

func Info(args ...interface{})

Info logs an info message

func Infof

func Infof(str string, args ...interface{})

Infof logs an info message using formatting like fmt.Printf

func Initialize

func Initialize(cfg Options) error

Initialize sets up the logging interface for use without the server

func Warn

func Warn(args ...interface{})

Warn logs a warning message

func Warnf

func Warnf(str string, args ...interface{})

Warnf logs a warning message using formatting lime fmt.Printf

Types

type Options

type Options struct {
	//Path holds the file path to write logs too.
	//If this value is empty, then no file writing is
	//done and only STDOUT will be used
	Path string `json:"path"`

	//Level sets the logging level in which only
	//messages at, or above, this level will be witten.
	//The values expected are:
	//	DEBUG,INFO,WARN,ERROR
	//Where the default is INFO
	Level string `json:"level"`

	//Usage enables the logging of connection specific
	//messages
	Usage bool `json:"usage"`

	//BlurTimes tells the logging facilities to
	//round any access time logs to protect
	//user privacy
	BlurTimes uint `json:"blurTimes"`

	//ShowAddress enables the logging of connection
	//addresses during usage messages
	ShowAddress bool `json:"showRemoteAddresses"`
}

Options holds the configuration settings for the logging operations. This is JSON serializable so we can load from a file.

func CombineOptions

func CombineOptions(opts ...Options) (Options, error)

CombineOptions takes a variable amount of LoggingOptions objects and merges them into a single object, taking carefully merging them using LoggingOptions.MergeFrom() method. The starting object is DefaultLoggingOptions, so if no parameters are provided, the defaults are returned. Returns the new object, or an error if the final result does not pass validation. The returned error is the validation error as returned by LoggingOptions.Verify()

func (Options) Equals

func (o Options) Equals(opt Options) bool

Equals returns true if this object deep equals the provided one

func (*Options) MergeFrom

func (o *Options) MergeFrom(opt Options) error

MergeFrom combines the values from the supplied LoggingOptions parameter into this current options. Taking care to only override things needed. Will verify the results and return the object for any validation errors.

Path will only be overriden if the supplied object has one

func (Options) Verify

func (o Options) Verify() error

Verify confirms that all the options are valid within the set. If not returns an error declaring the problem.

Jump to

Keyboard shortcuts

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