logger

package
v0.1.3-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logger manage a colored concurrent safe logger to substitute golang log package. This implementation is heavely base on github.com/fatih/color package (for all the coloring stuff).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogFacility

type LogFacility struct {
	// contains filtered or unexported fields
}

LogFacility logging facility structure.

func NewLogFacility

func NewLogFacility(prefix string, timestamp bool, colored bool) *LogFacility

NewLogFacility creates a new logging facility to manage differently colored logs. If a prefix is specified it'll be added to each logging message, a time stamp can be also printed on screen.

func (*LogFacility) CriticalLog

func (f *LogFacility) CriticalLog(fmt string, arg ...interface{}) (int, error)

CriticalLog prints critical logs using red color and bold font.

func (*LogFacility) ErrorLog

func (f *LogFacility) ErrorLog(fmt string, arg ...interface{}) (int, error)

ErrorLog prints errors using red color.

func (*LogFacility) MessageLog

func (f *LogFacility) MessageLog(fmt string, arg ...interface{}) (int, error)

MessageLog generic green logs.

func (*LogFacility) VerboseLog

func (f *LogFacility) VerboseLog(fmt string, arg ...interface{}) (int, error)

VerboseLog print white verbose logs.

func (*LogFacility) WarningLog

func (f *LogFacility) WarningLog(fmt string, arg ...interface{}) (int, error)

WarningLog prints warnings using yellow color.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger single colored logger structure.

func NewLogger

func NewLogger(color *color.Color,
	prefix, tag string,
	timestamp bool,
	colored bool) *Logger

NewLogger creates a new colored logger starting from a fatih color Color struct.

func (*Logger) Color

func (l *Logger) Color(str string) string

Color colors the argument string.

func (*Logger) Print

func (l *Logger) Print(arg ...interface{}) (int, error)

Print replace fmt.Print() function.

func (*Logger) Printf

func (l *Logger) Printf(f string, arg ...interface{}) (int, error)

Printf replace fmt.Printf() function.

func (*Logger) Println

func (l *Logger) Println(arg ...interface{}) (int, error)

Println prints a single line using specified color.

func (*Logger) Sprintf

func (l *Logger) Sprintf(f string, arg ...interface{}) string

Sprintf colors a specific format string.

Jump to

Keyboard shortcuts

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