slog

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 7 Imported by: 0

README

slog

Go logger designed for REST services - intended to be used with lightwork

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrettyDuration added in v0.0.3

type PrettyDuration time.Duration

func (PrettyDuration) MarshalText added in v0.0.3

func (pd PrettyDuration) MarshalText() (text []byte, err error)

func (PrettyDuration) String added in v0.0.3

func (pd PrettyDuration) String() string

type Slogger

type Slogger struct {
	Writer io.Writer
	Mode   SloggerMode
}

func (*Slogger) NewRequest

func (s *Slogger) NewRequest(writeLogsHook func(sr *SloggerRequest)) (sr *SloggerRequest)

type SloggerEvent added in v0.0.3

type SloggerEvent struct {
	Severity SloggerEventSeverity
	Message  string
}

type SloggerEventSeverity

type SloggerEventSeverity string
const (
	SeverityInfo    SloggerEventSeverity = "info"
	SeverityWarning SloggerEventSeverity = "warning"
	SeverityError   SloggerEventSeverity = "error"
	SeverityWTF     SloggerEventSeverity = "wtf"
)

type SloggerMode

type SloggerMode int
const (
	ModeDevelopment SloggerMode = iota
	ModeProduction
)

type SloggerRequest

type SloggerRequest struct {
	ClientHost      string
	HttpMethod      string
	HttpPath        string
	HttpStatusCode  int
	ResponseSize    int64
	RequestTime     time.Time
	RequestDuration PrettyDuration
	ExtraData       map[string]interface{}
	Events          []SloggerEvent
	// contains filtered or unexported fields
}

func (*SloggerRequest) Error

func (sr *SloggerRequest) Error(msg string)

func (*SloggerRequest) FormatLog

func (sr *SloggerRequest) FormatLog(format string, values ...interface{}) (msg string)

func (*SloggerRequest) Info

func (sr *SloggerRequest) Info(msg string)

func (*SloggerRequest) WTF

func (sr *SloggerRequest) WTF(msg string)

func (*SloggerRequest) Warning

func (sr *SloggerRequest) Warning(msg string)

func (*SloggerRequest) WriteLogs

func (sr *SloggerRequest) WriteLogs()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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