log

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PropertyKeySessionID is the session id of current logger
	PropertyKeySessionID = "SessionID"
	// PropertyKeyContextID is the context id of current logger
	PropertyKeyContextID = "ContextID"
	// PropertyKeyUserID is the user id of current logger
	PropertyKeyUserID = "UserID"
	// PropertyKeyTenantID is the tenant id of current logger
	PropertyKeyTenantID = "TenantID"
)

Variables

This section is empty.

Functions

func Blue

func Blue(content interface{}) string

Blue return content with blue color

func Bold

func Bold(content interface{}) string

Bold return content with bold text

func Color added in v0.14.0

func Color(colorName string, content interface{}) string

Color return content with given color

func Green

func Green(content interface{}) string

Green return content with green color

func Magenta

func Magenta(content interface{}) string

Magenta return content with magenta color

func Parse added in v0.14.0

func Parse(format string, props Props, colorize bool) string

Parse is used to merge props into format and return a text message

func Red

func Red(content interface{}) string

Red return content with red color

func Reverse

func Reverse(content interface{}) string

Reverse return content with reverse colors

func Yellow

func Yellow(content interface{}) string

Yellow return content with yellow color

Types

type Level

type Level uint8

Level defines all possible log levels

const (
	// DEBUG for verbose logs
	DEBUG Level = iota + 1
	// INFO for WARN+ERROR+INFO logs
	INFO
	// WARN for WARN+ERROR logs
	WARN
	// ERROR for ERROR only logs
	ERROR
	// NONE is used to disable logs
	NONE
)

func ParseLevel added in v0.14.0

func ParseLevel(level string) Level

ParseLevel returns a log.Level based on input string

func (Level) String added in v0.14.0

func (l Level) String() string

type Logger

type Logger interface {
	Disable()
	Enable()
	SetLevel(level Level)
	SetProperty(key string, value interface{})
	Debug(message string)
	Debugf(message string, props Props)
	Info(message string)
	Infof(message string, props Props)
	Warn(format string)
	Warnf(message string, props Props)
	Error(err error)
	Errorf(message string, props Props)
	IsEnabled(level Level) bool
	Write(p []byte) (int, error)
	New() Logger
}

Logger defines the logging interface.

type Props added in v0.14.0

type Props map[string]interface{}

Props is a map of key:value

func (Props) Merge added in v0.14.0

func (p Props) Merge(props Props) Props

Merge current props with given props

func (Props) Value added in v0.14.0

func (p Props) Value() (driver.Value, error)

Value converts props into a database value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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