logger

package
v0.0.0-...-6b3dfbf Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Disable = false

Disable disables all logging, false by default. (used for "go test")

View Source
var ErrCritical struct{}

ErrCritical is the value panic'd whenever CriticalIf is called.

Functions

func CriticalIf

func CriticalIf(ctx context.Context, err error)

CriticalIf logs the provided error on the console. It fails the current go-routine by causing a `panic(ErrCritical)`.

func EnableJSON

func EnableJSON()

EnableJSON - outputs logs in json format.

func EnableQuiet

func EnableQuiet()

EnableQuiet - turns quiet option on.

func Fatal

func Fatal(err error, msg string, data ...interface{})

Fatal prints only fatal error message without no stack trace it will be called for input validation failures

func FatalIf

func FatalIf(err error, msg string, data ...interface{})

FatalIf is similar to Fatal() but it ignores passed nil error

func Info

func Info(msg string, data ...interface{})

Info :

func Init

func Init(goPath string, goRoot string)

Init sets the trimStrings to possible GOPATHs and GOROOT directories. Also append github.com/piensa/nodo This is done to clean up the filename, when stack trace is displayed when an error happens.

func LogIf

func LogIf(ctx context.Context, err error)

LogIf prints a detailed error message during the execution of the server.

func LogOnceIf

func LogOnceIf(ctx context.Context, err error, id interface{})

LogOnceIf - Logs notification errors - once per error. id is a unique identifier for related log messages, refer to cmd/notification.go on how it is used.

func RegisterUIError

func RegisterUIError(f func(string, error, bool) string)

RegisterUIError registers the specified rendering function. This latter will be called for a pretty rendering of fatal errors.

func SetReqInfo

func SetReqInfo(ctx context.Context, req *ReqInfo) context.Context

SetReqInfo sets ReqInfo in the context.

func StartupMessage

func StartupMessage(msg string, data ...interface{})

StartupMessage :

Types

type Console

type Console interface {
	// contains filtered or unexported methods
}

Console interface describes the methods that needs to be implemented to satisfy the interface requirements.

type KeyVal

type KeyVal struct {
	Key string
	Val string
}

KeyVal - appended to ReqInfo.Tags

type Level

type Level int8

Level type

const (
	InformationLvl Level = iota + 1
	ErrorLvl
	FatalLvl
)

Enumerated level types

func (Level) String

func (level Level) String() string

type ReqInfo

type ReqInfo struct {
	RemoteHost string // Client Host/IP
	UserAgent  string // User Agent
	RequestID  string // x-amz-request-id
	API        string // API name - GetObject PutObject NewMultipartUpload etc.
	BucketName string // Bucket name
	ObjectName string // Object name

	sync.RWMutex
	// contains filtered or unexported fields
}

ReqInfo stores the request info.

func GetReqInfo

func GetReqInfo(ctx context.Context) *ReqInfo

GetReqInfo returns ReqInfo if set.

func NewReqInfo

func NewReqInfo(remoteHost, userAgent, requestID, api, bucket, object string) *ReqInfo

NewReqInfo :

func (*ReqInfo) AppendTags

func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo

AppendTags - appends key/val to ReqInfo.tags

func (*ReqInfo) GetTags

func (r *ReqInfo) GetTags() []KeyVal

GetTags - returns the user defined tags

Jump to

Keyboard shortcuts

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