log

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close closes logger and its channel.

func Debug

func Debug(msg Message)

Debug prints message in debug mode.

func Error

func Error(msg Message)

Error prints message in error mode.

func Info

func Info(msg Message)

Info prints message in info mode.

func Init

func Init(level string, json bool)

Init inits global logger.

func Stat

func Stat(msg Message)

Stat prints stat message regardless of the log level with info print formatting. It uses printfHelper instead of printf to ignore the log level condition.

func Trace

func Trace(msg Message)

Trace prints message in trace mode.

Types

type DebugMessage

type DebugMessage struct {
	Operation string `json:"operation,omitempty"`
	Command   string `json:"job,omitempty"`
	Err       string `json:"error"`
}

DebugMessage is a generic message structure for unsuccessful operations.

func (DebugMessage) JSON

func (d DebugMessage) JSON() string

JSON is the JSON representation of ErrorMessage.

func (DebugMessage) String

func (d DebugMessage) String() string

String is the string representation of ErrorMessage.

type ErrorMessage

type ErrorMessage struct {
	Operation string `json:"operation,omitempty"`
	Command   string `json:"command,omitempty"`
	Err       string `json:"error"`
}

ErrorMessage is a generic message structure for unsuccessful operations.

func (ErrorMessage) JSON

func (e ErrorMessage) JSON() string

JSON is the JSON representation of ErrorMessage.

func (ErrorMessage) String

func (e ErrorMessage) String() string

String is the string representation of ErrorMessage.

type InfoMessage

type InfoMessage struct {
	Operation   string   `json:"operation"`
	Success     bool     `json:"success"`
	Source      *url.URL `json:"source,omitempty"`
	Destination *url.URL `json:"destination,omitempty"`
	Object      Message  `json:"object,omitempty"`

	// the VersionID field exist only for JSON Marshall, it must not be used for
	// any other purpose.
	VersionID string `json:"version_id,omitempty"`
}

InfoMessage is a generic message structure for successful operations.

func (InfoMessage) JSON

func (i InfoMessage) JSON() string

JSON is the JSON representation of InfoMessage.

func (InfoMessage) String

func (i InfoMessage) String() string

String is the string representation of InfoMessage.

type LogLevel

type LogLevel int

LogLevel is the level of Logger.

const (
	LevelTrace LogLevel = iota
	LevelDebug
	LevelInfo
	LevelError
)

func LevelFromString

func LevelFromString(s string) LogLevel

LevelFromString returns logLevel for given string. It return `levelInfo` as a default.

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of logLevel.

type Logger

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

Logger is a structure for logging messages.

func New

func New(level string, json bool) *Logger

New creates new logger.

type Message

type Message interface {
	fmt.Stringer
	JSON() string
}

Message is an interface to print structured logs.

type TraceMessage

type TraceMessage struct {
	Message string `json:"message"`
}

func (TraceMessage) JSON

func (t TraceMessage) JSON() string

func (TraceMessage) String

func (t TraceMessage) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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