go-logger: github.com/apsdehal/go-logger Index | Files | Directories

package logger

import "github.com/apsdehal/go-logger"

Package name declaration

Index

Package Files

logger.go

Constants

const (
    Black = (iota + 30)
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
)

Color numbers for stdout

func SetDefaultFormat Uses

func SetDefaultFormat(format string)

func Stack Uses

func Stack() string

Returns a string with the execution stack for this goroutine

type Info Uses

type Info struct {
    Id       uint64
    Time     string
    Module   string
    Level    LogLevel
    Line     int
    Filename string
    Message  string
}

Info class, Contains all the info on what has to logged, time is the current time, Module is the specific module For which we are logging, level is the state, importance and type of message logged, Message contains the string to be logged, format is the format of string to be passed to sprintf

func (*Info) Output Uses

func (r *Info) Output(format string) string

Returns a proper string to be outputted for a particular info

type LogLevel Uses

type LogLevel int

LogLevel type

const (
    CriticalLevel LogLevel = iota + 1
    ErrorLevel
    WarningLevel
    NoticeLevel
    InfoLevel
    DebugLevel
)

Log Level

type Logger Uses

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

Logger class that is an interface to user to log messages, Module is the module for which we are testing worker is variable of Worker class that is used in bottom layers to log the message

func New Uses

func New(args ...interface{}) (*Logger, error)

Returns a new instance of logger class, module is the specific module for which we are logging , color defines whether the output is to be colored or not, out is instance of type io.Writer defaults to os.Stderr

func (*Logger) Critical Uses

func (l *Logger) Critical(message string)

Critical logs a message at a Critical Level

func (*Logger) CriticalF Uses

func (l *Logger) CriticalF(format string, a ...interface{})

CriticalF logs a message at Critical level using the same syntax and options as fmt.Printf

func (*Logger) Criticalf Uses

func (l *Logger) Criticalf(format string, a ...interface{})

CriticalF logs a message at Critical level using the same syntax and options as fmt.Printf

func (*Logger) Debug Uses

func (l *Logger) Debug(message string)

Debug logs a message at Debug level

func (*Logger) DebugF Uses

func (l *Logger) DebugF(format string, a ...interface{})

DebugF logs a message at Debug level using the same syntax and options as fmt.Printf

func (*Logger) Debugf Uses

func (l *Logger) Debugf(format string, a ...interface{})

DebugF logs a message at Debug level using the same syntax and options as fmt.Printf

func (*Logger) Error Uses

func (l *Logger) Error(message string)

Error logs a message at Error level

func (*Logger) ErrorF Uses

func (l *Logger) ErrorF(format string, a ...interface{})

ErrorF logs a message at Error level using the same syntax and options as fmt.Printf

func (*Logger) Errorf Uses

func (l *Logger) Errorf(format string, a ...interface{})

ErrorF logs a message at Error level using the same syntax and options as fmt.Printf

func (*Logger) Fatal Uses

func (l *Logger) Fatal(message string)

Fatal is just like func l.Critical logger except that it is followed by exit to program

func (*Logger) FatalF Uses

func (l *Logger) FatalF(format string, a ...interface{})

FatalF is just like func l.CriticalF logger except that it is followed by exit to program

func (*Logger) Fatalf Uses

func (l *Logger) Fatalf(format string, a ...interface{})

FatalF is just like func l.CriticalF logger except that it is followed by exit to program

func (*Logger) Info Uses

func (l *Logger) Info(message string)

Info logs a message at Info level

func (*Logger) InfoF Uses

func (l *Logger) InfoF(format string, a ...interface{})

InfoF logs a message at Info level using the same syntax and options as fmt.Printf

func (*Logger) Infof Uses

func (l *Logger) Infof(format string, a ...interface{})

InfoF logs a message at Info level using the same syntax and options as fmt.Printf

func (*Logger) Log Uses

func (l *Logger) Log(lvl LogLevel, message string)

The log commnand is the function available to user to log message, lvl specifies the degree of the messagethe user wants to log, message is the info user wants to log

func (*Logger) Notice Uses

func (l *Logger) Notice(message string)

Notice logs a message at Notice level

func (*Logger) NoticeF Uses

func (l *Logger) NoticeF(format string, a ...interface{})

NoticeF logs a message at Notice level using the same syntax and options as fmt.Printf

func (*Logger) Noticef Uses

func (l *Logger) Noticef(format string, a ...interface{})

NoticeF logs a message at Notice level using the same syntax and options as fmt.Printf

func (*Logger) Panic Uses

func (l *Logger) Panic(message string)

Panic is just like func l.Critical except that it is followed by a call to panic

func (*Logger) PanicF Uses

func (l *Logger) PanicF(format string, a ...interface{})

PanicF is just like func l.CriticalF except that it is followed by a call to panic

func (*Logger) Panicf Uses

func (l *Logger) Panicf(format string, a ...interface{})

PanicF is just like func l.CriticalF except that it is followed by a call to panic

func (*Logger) SetFormat Uses

func (l *Logger) SetFormat(format string)

func (*Logger) SetLogLevel Uses

func (l *Logger) SetLogLevel(level LogLevel)

func (*Logger) StackAsCritical Uses

func (l *Logger) StackAsCritical(message string)

Prints this goroutine's execution stack as critical with an optional message at the begining

func (*Logger) StackAsError Uses

func (l *Logger) StackAsError(message string)

Prints this goroutine's execution stack as an error with an optional message at the begining

func (*Logger) Warning Uses

func (l *Logger) Warning(message string)

Warning logs a message at Warning level

func (*Logger) WarningF Uses

func (l *Logger) WarningF(format string, a ...interface{})

WarningF logs a message at Warning level using the same syntax and options as fmt.Printf

func (*Logger) Warningf Uses

func (l *Logger) Warningf(format string, a ...interface{})

WarningF logs a message at Warning level using the same syntax and options as fmt.Printf

type Worker Uses

type Worker struct {
    Minion *log.Logger
    Color  int
    // contains filtered or unexported fields
}

Worker class, Worker is a log object used to log messages and Color specifies if colored output is to be produced

func NewWorker Uses

func NewWorker(prefix string, flag int, color int, out io.Writer) *Worker

Returns an instance of worker class, prefix is the string attached to every log, flag determine the log params, color parameters verifies whether we need colored outputs or not

func (*Worker) Log Uses

func (w *Worker) Log(level LogLevel, calldepth int, info *Info) error

Function of Worker class to log a string based on level

func (*Worker) SetFormat Uses

func (w *Worker) SetFormat(format string)

func (*Worker) SetLogLevel Uses

func (w *Worker) SetLogLevel(level LogLevel)

Directories

PathSynopsis
examples

Package logger imports 10 packages (graph) and is imported by 10 packages. Updated 2019-05-16. Refresh now. Tools for package owners.