lumber

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

Go-Lumber

Code Climate maintainability Code Climate coverage

Go lumber is a simple, yet opinionated little logging library that I seem to write into a lot of my packages, so I decided to make it a library instead of re-writing it every time.

Documentation is available via godoc here: https://godoc.org/github.com/j4ng5y/go-lumber

Installation

go get -u github.com/j4ng5y/go-lumber

Usage

To use this library, you can do something like the following:

package main

import "github.com/j4ng5y/go-lumber"

func main() {
    log := lumber.New()

    data, err := ErroniousFunction()
    if err != nil {
        log.Errorf("this function failed: %v", err)
    }
}

You can also set a log file in addition to just writing to STDOUT by doing the following:

...
log := lumber.New()

log.SetLogFile("debug", "debug.log")
...

and then use the library like normal.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lumber

type Lumber struct {
	DebugLog        *log.Logger
	DebugFileLogger *log.Logger
	InfoLog         *log.Logger
	InfoFileLogger  *log.Logger
	WarnLog         *log.Logger
	WarnFileLogger  *log.Logger
	ErrorLog        *log.Logger
	ErrorFileLogger *log.Logger
	FatalLog        *log.Logger
	FatalFileLogger *log.Logger
}

Lumber is a struct to hold loggers

func New

func New() *Lumber

New returns a new instance of Lumber This default behaviour will log everything to STDOUT

Arguments:

None

Returns:

(*Lumber): A pointer to the newly created instance of Lumber

func (Lumber) Debug

func (L Lumber) Debug(msg string)

Debug takes a message string and logs that message

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Debugf

func (L Lumber) Debugf(format string, v ...interface{})

Debugf takes a formatted message string and logs that message as a debug message

Arguments:

format (string): The formatted message to log
v (...interface{}): any number of variables to use to format the message

Returns:

None

func (Lumber) Debugln

func (L Lumber) Debugln(msg string)

Debugln takes a message string and logs that message with a newline inluded

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Error

func (L Lumber) Error(msg string)

Error takes a message string and logs that message as a erronious message

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Errorf

func (L Lumber) Errorf(format string, v ...interface{})

Errorf takes a formatted message string and logs that message as an erronious message

Arguments:

format (string): The formatted message to log
v (...interface{}): any number of variables to use to format the message

Returns:

None

func (Lumber) Errorln

func (L Lumber) Errorln(msg string)

Errorln takes a message string and logs that message with a newline inluded

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Fatal

func (L Lumber) Fatal(msg string, exitCode int)

Fatal takes a message string and logs that message as a fatal message

Arguments:

msg (string):   The message to log
exitCode (int): The exit code to exit the application with

Returns:

None

func (Lumber) Fatalf

func (L Lumber) Fatalf(exitCode int, format string, v ...interface{})

Fatalf takes a formatted message string and logs that message as a fatal message

Arguments:

exitCode (int):     The exit code to exit the application with
format (string):    The formatted message to log
v (...interface{}): Any number of variables to use to format the message

Returns:

None

func (Lumber) Fatalln

func (L Lumber) Fatalln(msg string, exitCode int)

Fatalln takes a message string and logs that message as a fatal message with a newline inluded

Arguments:

msg (string):   The message to log
exitCode (int): The exit code to exit the application with

Returns:

None

func (Lumber) Info

func (L Lumber) Info(msg string)

Info takes a message string and logs that message as an info message

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Infof

func (L Lumber) Infof(format string, v ...interface{})

Infof takes a formatted message string and logs that message as an info message

Arguments:

format (string): The formatted message to log
v (...interface{}): any number of variables to use to format the message

Returns:

None

func (Lumber) Infoln

func (L Lumber) Infoln(msg string)

Infoln takes a message string and logs that message with a newline inluded

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) SetLogFile

func (L Lumber) SetLogFile(logLevel string, filename string) error

SetLogFile will set a log file for the provided logger

Arguments:

filename (string): the name of the file to write
l (*log.Logger): the lumber logger to set this output file for

Returns:

(error): an error if one exists, nil otherwise

func (Lumber) Warn

func (L Lumber) Warn(msg string)

Warn takes a message string and logs that message as a warning message

Arguments:

msg (string): The message to log

Returns:

None

func (Lumber) Warnf

func (L Lumber) Warnf(format string, v ...interface{})

Warnf takes a formatted message string and logs that message as a warning message

Arguments:

format (string): The formatted message to log
v (...interface{}): any number of variables to use to format the message

Returns:

None

func (Lumber) Warnln

func (L Lumber) Warnln(msg string)

Warnln takes a message string and logs that message with a newline inluded

Arguments:

msg (string): The message to log

Returns:

None

Jump to

Keyboard shortcuts

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