log

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package log implements a logger interface that can be used within the go-mail package

Index

Constants

View Source
const (
	// DirString is a constant used for the structured logger
	DirString = "direction"
	// DirFromString is a constant used for the structured logger
	DirFromString = "from"
	// DirToString is a constant used for the structured logger
	DirToString = "to"
)
View Source
const CallDepth = 2

CallDepth is the call depth value for the log.Logger's Output method This defaults to 2 and is only here for better readablity of the code

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction added in v0.4.1

type Direction int

Direction is a type wrapper for the direction a debug log message goes

const (
	DirServerToClient Direction = iota // Server to Client communication
	DirClientToServer                  // Client to Server communication
)

type JSONlog added in v0.4.1

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

JSONlog is the default structured JSON logger that satisfies the Logger interface

func NewJSON added in v0.4.1

func NewJSON(o io.Writer, l Level) *JSONlog

NewJSON returns a new JSONlog type that satisfies the Logger interface

func (*JSONlog) Debugf added in v0.4.1

func (l *JSONlog) Debugf(lo Log)

Debugf logs a debug message via the structured JSON logger

func (*JSONlog) Errorf added in v0.4.1

func (l *JSONlog) Errorf(lo Log)

Errorf logs a warn message via the structured JSON logger

func (*JSONlog) Infof added in v0.4.1

func (l *JSONlog) Infof(lo Log)

Infof logs a info message via the structured JSON logger

func (*JSONlog) Warnf added in v0.4.1

func (l *JSONlog) Warnf(lo Log)

Warnf logs a warn message via the structured JSON logger

type Level

type Level int

Level is a type wrapper for an int

const (
	// LevelError is the Level for only ERROR log messages
	LevelError Level = iota
	// LevelWarn is the Level for WARN and higher log messages
	LevelWarn
	// LevelInfo is the Level for INFO and higher log messages
	LevelInfo
	// LevelDebug is the Level for DEBUG and higher log messages
	LevelDebug
)

type Log added in v0.4.1

type Log struct {
	Direction Direction
	Format    string
	Messages  []interface{}
}

Log represents a log message type that holds a log Direction, a Format string and a slice of Messages

type Logger

type Logger interface {
	Debugf(Log)
	Infof(Log)
	Warnf(Log)
	Errorf(Log)
}

Logger is the log interface for go-mail

type Stdlog

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

Stdlog is the default logger that satisfies the Logger interface

func New

func New(o io.Writer, l Level) *Stdlog

New returns a new Stdlog type that satisfies the Logger interface

func (*Stdlog) Debugf

func (l *Stdlog) Debugf(lo Log)

Debugf performs a Printf() on the debug logger

func (*Stdlog) Errorf

func (l *Stdlog) Errorf(lo Log)

Errorf performs a Printf() on the error logger

func (*Stdlog) Infof

func (l *Stdlog) Infof(lo Log)

Infof performs a Printf() on the info logger

func (*Stdlog) Warnf

func (l *Stdlog) Warnf(lo Log)

Warnf performs a Printf() on the warn logger

Jump to

Keyboard shortcuts

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