xlogger

package
v0.0.0-...-796497b Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(i ...interface{})

Debug prints to output values i joined with a space. Will add the assigned Debug tag and color.

func Debugf

func Debugf(f string, i ...interface{})

Debugf prints to output f formatted with values i. Uses the go standard library style format strings. Will add the assigned Debug tag and color.

func Error

func Error(i ...interface{})

Error prints to output values i joined with a space. Will add the assigned Error tag and color.

func Errorf

func Errorf(f string, i ...interface{})

Errorf prints to output f formatted with values i. Uses the go standard library style format strings. Will add the assigned Error tag and color.

func Fatal

func Fatal(exit func(int), i ...interface{})

Fatal prints to output values i joined with a space. Will add the assigned Fatal tag and color.

func Fatalf

func Fatalf(exit func(int), f string, i ...interface{})

Fatalf prints to output f formatted with values i. Uses the go standard library style format strings. Will add the assigned Fatal tag and color.

func GetHTMLOutput

func GetHTMLOutput() io.Writer

func GetHTMLStatus

func GetHTMLStatus() bool

func Info

func Info(i ...interface{})

Info prints to output values i joined with a space. Will add the assigned Info tag and color.

func Infof

func Infof(f string, i ...interface{})

Infof prints to output f formatted with values i. Uses the go standard library style format strings. Will add the assigned Info tag and color.

func SetFormat

func SetFormat(format string)

SetFormat will set the logger to format all output. The format string MUST have a {TIME}, {TAG}, {MSG} string inside. For example: `{TIME} [{TAG}]:> {MSG}` will print logs of the form `10-21-1975 13:24:56 ERROR:> this is the message` Be careful, this will just do nothing if the format is invalid.

func SetHTMLOutput

func SetHTMLOutput(out io.Writer)

SetHTMLOutput sets where the logger will write to

func SetHTMLStatus

func SetHTMLStatus(status bool, addr string)

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets where the logger will write to

func SetTimeFormat

func SetTimeFormat(format string)

SetTimeFormat sets the time format for the time stamp on a log line Uses the go standard library timeformat format.

func Warn

func Warn(i ...interface{})

Warn prints to output values i joined with a space. Will add the assigned Warn tag and color.

func Warnf

func Warnf(f string, i ...interface{})

Warnf prints to output f formatted with values i. Uses the go standard library style format strings. Will add the assigned Warn tag and color.

Types

type Color

type Color struct {
	colorize.IColorize
	// contains filtered or unexported fields
}

func (*Color) Dup

func (c *Color) Dup() IColor

func (*Color) Get

func (c *Color) Get() IColor

func (*Color) Set

func (c *Color) Set(color IColor)

type Format

type Format struct {
	StringGetSetter
}

Format struct holds the format of log messages. The Format string MUST have a {TIME}, {TAG}, {MSG} string inside. For example: `{TIME} [{TAG}]:> {MSG}` will print logs of the form `10-21-1975 13:24:56 ERROR:> this is the message`

func (*Format) Dup

func (f *Format) Dup() IFormat

Dup duplicates the format

type IColor

type IColor interface {
	colorize.IColorize
	Get() IColor
	Set(IColor)
	Dup() IColor
}

func NewColor

func NewColor(cz ...colorize.IColorize) IColor

type IFormat

type IFormat interface {
	IStringGetSetter
	Dup() IFormat
}

func NewFormat

func NewFormat(format string) IFormat

NewFormat creates a Format from a string. If the format is not valid it will return nil

type IStringGetSetter

type IStringGetSetter interface {
	IStringGetter
	IStringSetter
}

type IStringGetter

type IStringGetter interface {
	Get() string
}

type IStringSetter

type IStringSetter interface {
	Set(string)
}

type ITag

type ITag interface {
	IStringGetSetter
	Dup() ITag
}

func NewTag

func NewTag(tag string) ITag

NewTag creates a new Tag

type ITier

type ITier interface {
	GetColor() IColor
	SetColor(IColor)
	GetTag() ITag
	SetTag(ITag)
	GetFormat() IFormat
	SetFormat(IFormat)
	GetTimeFormat() ITimeFormat
	SetTimeFormat(ITimeFormat)
	GetWriter() io.Writer
	SetWriter(io.Writer)
	Dup() ITier
	Log(msg ...interface{})
	Logf(format string, params ...interface{})
}

func Get

func Get(idx int) ITier

Get will get the tier at idx

func GetDebug

func GetDebug() ITier

GetDebug gets the info tier

func GetError

func GetError() ITier

GetError gets the info tier

func GetFatal

func GetFatal() ITier

GetFatal gets the info tier

func GetInfo

func GetInfo() ITier

GetInfo gets the info tier

func GetWarn

func GetWarn() ITier

GetWarn gets the info tier

func NewTier

func NewTier(color IColor, tag ITag, format IFormat, timeFormat ITimeFormat, writer io.Writer) ITier

NewTier Creates a new Tier with the desired properties

type ITimeFormat

type ITimeFormat interface {
	IStringGetSetter
	Dup() ITimeFormat
}

func NewTimeFormat

func NewTimeFormat(format string) ITimeFormat

NewTimeFormat creates a new TimeFormat

type Logger

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

func NewLogger

func NewLogger(tiers ...ITier) *Logger

func (*Logger) Add

func (l *Logger) Add(tiers ...ITier) *Logger

Add will add a tier to the tail end of the logger

func (*Logger) Get

func (l *Logger) Get(idx int) ITier

Get will get the tier at index idx, it will return nil if the index is out of bounds.

func (*Logger) GetOutput

func (l *Logger) GetOutput() io.Writer

func (*Logger) SetFormat

func (l *Logger) SetFormat(format string)

SetFormat will set the logger to format all output. The format string MUST have a {TIME}, {TAG}, {MSG} string inside. For example: `{TIME} [{TAG}]:> {MSG}` will print logs of the form `10-21-1975 13:24:56 ERROR:> this is the message` Be careful, this will just do nothing if the format is invalid.

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

SetOutput sets where the logger will write to

func (*Logger) SetTimeFormat

func (l *Logger) SetTimeFormat(format string)

SetTimeFormat sets the time format for the time stamp on a log line Uses the go standard library timeformat format.

type StringGetSetter

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

StringGetSetter is the base type for Color, Tag, Format, and TimeFormat

func (*StringGetSetter) Get

func (s *StringGetSetter) Get() string

Get will return the string (thread safe)

func (*StringGetSetter) Set

func (s *StringGetSetter) Set(str string)

Set will set the string (thread safe)

type Tag

type Tag struct {
	StringGetSetter
}

Tag is the type used for Tags

func (*Tag) Dup

func (t *Tag) Dup() ITag

Dup duplicates the Tag

type Tier

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

Tier holds the properties for a logger tier.

func (*Tier) Dup

func (t *Tier) Dup() ITier

Dup duplicates a tier

func (*Tier) GetColor

func (t *Tier) GetColor() IColor

GetColor Returns the color property of the tier

func (*Tier) GetFormat

func (t *Tier) GetFormat() IFormat

GetFormat gets the format property.

func (*Tier) GetTag

func (t *Tier) GetTag() ITag

GetTag returns the tag property

func (*Tier) GetTimeFormat

func (t *Tier) GetTimeFormat() ITimeFormat

GetTimeFormat gets the time format property

func (*Tier) GetWriter

func (t *Tier) GetWriter() io.Writer

GetWriter gets the writer property

func (*Tier) Log

func (t *Tier) Log(msgs ...interface{})

Log will log a line to writer

func (*Tier) Logf

func (t *Tier) Logf(format string, params ...interface{})

Logf will log a formated line to writer

func (*Tier) SetColor

func (t *Tier) SetColor(c IColor)

SetColor sets the color property of the tier

func (*Tier) SetFormat

func (t *Tier) SetFormat(format IFormat)

SetFormat sets the format property

func (*Tier) SetTag

func (t *Tier) SetTag(tag ITag)

SetTag sets the tag property

func (*Tier) SetTimeFormat

func (t *Tier) SetTimeFormat(timeFormat ITimeFormat)

SetTimeFormat sets the time format property

func (*Tier) SetWriter

func (t *Tier) SetWriter(writer io.Writer)

SetWriter sets the writer property

type TimeFormat

type TimeFormat struct {
	StringGetSetter
}

TimeFormat is the type used for formatting the time. Uses the same time format as the go standard library "time." example `Mon Jan _2 15:04:05 2006`

func (*TimeFormat) Dup

func (f *TimeFormat) Dup() ITimeFormat

Dup duplicates the TimeFormat

Jump to

Keyboard shortcuts

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