logger

package
v0.0.0-...-e9b145e Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuditTargets = []LoggingTarget{}

AuditTargets is the list of enabled audit loggers

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.

View Source
var Targets = []LoggingTarget{}

Targets is the set of enabled loggers

Functions

func AddAuditTarget

func AddAuditTarget(t LoggingTarget)

AddAuditTarget adds a new audit logger target to the list of enabled loggers

func AddTarget

func AddTarget(t LoggingTarget)

AddTarget adds a new logger target to the list of enabled loggers

func AuditLog

func AuditLog(ctx context.Context, w http.ResponseWriter, r *http.Request)

AuditLog - logs audit logs to all targets.

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/minio/minio This is done to clean up the filename, when stack trace is displayed when an error happens.

func LogAlwaysIf

func LogAlwaysIf(ctx context.Context, err error)

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

func LogIf

func LogIf(ctx context.Context, err error)

LogIf prints a detailed error message during the execution of the server, if it is not an ignored error.

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 SetDeploymentID

func SetDeploymentID(id string)

SetDeploymentID - Used to set the deployment ID, in XL and FS mode

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 AuditEntry

type AuditEntry struct {
	Version      string            `json:"version"`
	DeploymentID string            `json:"deploymentid,omitempty"`
	Time         string            `json:"time"`
	API          *api              `json:"api,omitempty"`
	RemoteHost   string            `json:"remotehost,omitempty"`
	RequestID    string            `json:"requestID,omitempty"`
	UserAgent    string            `json:"userAgent,omitempty"`
	ReqQuery     map[string]string `json:"requestQuery,omitempty"`
	ReqHeader    map[string]string `json:"requestHeader,omitempty"`
	RespHeader   map[string]string `json:"responseHeader,omitempty"`
}

AuditEntry - audit entry logs.

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 ConsoleTarget

type ConsoleTarget struct{}

ConsoleTarget implements loggerTarget to send log in plain or json format to the standard output.

type HTTPTarget

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

HTTPTarget implements loggerTarget and sends the json format of a log entry to the configured http endpoint. An internal buffer of logs is maintained but when the buffer is full, new logs are just ignored and an error is returned to the caller.

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 LoggingTarget

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

LoggingTarget is the entity that we will receive a single log entry and send it to the log target

e.g. send the log to a http server

func NewConsole

func NewConsole() LoggingTarget

NewConsole initializes a new logger target which prints log directly in the standard output.

func NewHTTP

func NewHTTP(endpoint string, transport *http.Transport) LoggingTarget

NewHTTP initializes a new logger target which sends log over http to the specified endpoint

func NewPydioTarget

func NewPydioTarget(logger PydioLogger) LoggingTarget

type PydioLogger

type PydioLogger interface {
	Info(entry interface{})
	Error(entry interface{})
	Audit(entry interface{})
}

type PydioTarget

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

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

func (*ReqInfo) SetTags

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

SetTags - sets key/val to ReqInfo.tags

Jump to

Keyboard shortcuts

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