log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 4 Imported by: 0

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

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

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

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

func NewJSON

func NewJSON(output io.Writer, level Level) *JSONlog

NewJSON returns a new JSONlog type that satisfies the Logger interface

func (*JSONlog) Debugf

func (l *JSONlog) Debugf(log Log)

Debugf logs a debug message via the structured JSON logger

func (*JSONlog) Errorf

func (l *JSONlog) Errorf(log Log)

Errorf logs a warn message via the structured JSON logger

func (*JSONlog) Infof

func (l *JSONlog) Infof(log Log)

Infof logs a info message via the structured JSON logger

func (*JSONlog) Warnf

func (l *JSONlog) Warnf(log 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

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(output io.Writer, level Level) *Stdlog

New returns a new Stdlog type that satisfies the Logger interface

func (*Stdlog) Debugf

func (l *Stdlog) Debugf(log Log)

Debugf performs a Printf() on the debug logger

func (*Stdlog) Errorf

func (l *Stdlog) Errorf(log Log)

Errorf performs a Printf() on the error logger

func (*Stdlog) Infof

func (l *Stdlog) Infof(log Log)

Infof performs a Printf() on the info logger

func (*Stdlog) Warnf

func (l *Stdlog) Warnf(log 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