logs

package
v0.0.0-...-ed3c113 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

mano/logs License Build Status

A simple, powerful and easy to use log Library for Go

Installation

$ go get -u -v github.com/junhwong/mano/logs

Usage


package main

import "github.com/junhwong/mano/logs"

func main(){
    logs.Debug("hello logs")

    logs.Debug("print red color text :{red:%s}","i'm red!")
}

Output:

screenshot

Changelog

Details changes for each release are documented in the release notes.

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

Apache-2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResetSetter = func() ColorSetter {
	color := ColorFormat(Reset)
	return func(isTerminal bool) string {
		if !isTerminal {
			return ""
		}
		return color
	}
}()

Functions

func ColorFormat

func ColorFormat(attrs ...ColorAttribute) string

func Debug

func Debug(message ...interface{})

func Error

func Error(message ...interface{})

func Fatal

func Fatal(message ...interface{})

func FormatLog

func FormatLog(isTerminal bool, entry *Entry) string

func Info

func Info(message ...interface{})

func IsDebugEnabled

func IsDebugEnabled() bool

func IsErrorEnabled

func IsErrorEnabled() bool

func IsFatalEnabled

func IsFatalEnabled() bool

func IsInfoEnabled

func IsInfoEnabled() bool

func IsLogStack

func IsLogStack() bool

func IsWarnEnabled

func IsWarnEnabled() bool

func Print

func Print(v ...interface{})

func Println

func Println(v ...interface{})

func SetLevel

func SetLevel(level Level)

func SetLogStack

func SetLogStack(logStack bool)

func SetProvider

func SetProvider(provider Provider)

func Warn

func Warn(message ...interface{})

Types

type ColorAttribute

type ColorAttribute int

ColorAttribute defines a single SGR Code

const (
	Reset ColorAttribute = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base attributes

const (
	FgBlack ColorAttribute = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack ColorAttribute = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

const (
	BgBlack ColorAttribute = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background text colors

const (
	BgHiBlack ColorAttribute = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background Hi-Intensity text colors

type ColorSetter

type ColorSetter func(isTerminal bool) string

func GetColorSetter

func GetColorSetter(name string) ColorSetter

func SetColorSetter

func SetColorSetter(name string, setter ColorSetter) ColorSetter

type Console

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

func NewConsole

func NewConsole() *Console

func (*Console) Log

func (c *Console) Log(entry *Entry)

func (*Console) Output

func (c *Console) Output() io.Writer

type Entry

type Entry struct {
	Time       time.Time
	Level      Level
	Message    []interface{}
	Caller     string
	Line       int
	Stack      []byte
	StackTrace []*runtime.Frame
}

type Exception

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

func NewError

func NewError(cause error, message ...interface{}) *Exception

NewError returns a Exception with the specified detail message and cause. cause is a optional

func (*Exception) Cause

func (ex *Exception) Cause() error

func (*Exception) Error

func (ex *Exception) Error() string

func (*Exception) Message

func (ex *Exception) Message() []interface{}

func (*Exception) Stack

func (ex *Exception) Stack() []byte

func (*Exception) Trace

func (ex *Exception) Trace() []*runtime.Frame

type Level

type Level uint8
const (
	LDEBUG Level = iota
	LTRACE
	LINFO
	LWARN
	LERROR
	LFATAL
)

func GetLevel

func GetLevel() Level

func (Level) Lable

func (level Level) Lable() string

type Logger

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

func NewLogger

func NewLogger(name string, provider ...Provider) *Logger

func (*Logger) Debug

func (l *Logger) Debug(message ...interface{})

func (*Logger) Error

func (l *Logger) Error(message ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(message ...interface{})

func (*Logger) Info

func (l *Logger) Info(message ...interface{})

func (*Logger) IsDebugEnabled

func (l *Logger) IsDebugEnabled() bool

func (*Logger) IsErrorEnabled

func (l *Logger) IsErrorEnabled() bool

func (*Logger) IsFatalEnabled

func (l *Logger) IsFatalEnabled() bool

func (*Logger) IsInfoEnabled

func (l *Logger) IsInfoEnabled() bool

func (*Logger) IsLogStack

func (l *Logger) IsLogStack() bool

func (*Logger) IsWarnEnabled

func (l *Logger) IsWarnEnabled() bool

func (*Logger) Level

func (l *Logger) Level() Level

func (*Logger) Name

func (l *Logger) Name() string

func (*Logger) Provider

func (l *Logger) Provider() Provider

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetLogStack

func (l *Logger) SetLogStack(logStack bool)

func (*Logger) SetProvider

func (l *Logger) SetProvider(provider Provider)

func (*Logger) Warn

func (l *Logger) Warn(message ...interface{})

type Provider

type Provider interface {
	Output() io.Writer
	Log(entry *Entry)
}

func GetProvider

func GetProvider() Provider

Jump to

Keyboard shortcuts

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