mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-13 01:12:55 +01:00
Winni Neessen
1c5c1e318c
The logging system in the smtp.go and log package has been refactored. A new custom log type `Log` was introduced, that includes the message direction, format and arguments. The `Logger` interface and the `Stdlog` implementation were modified to accept this new type. This change provides a clearer understanding of message direction inside logs, allowing for easier debugging and reduced complexity. This change does not affect features or disrupt user functionality. Additionally, it allows for custom implementations of the log.Logger interface to without being forced to use the C --> S/C <-- S direction logging.
30 lines
766 B
Go
30 lines
766 B
Go
// SPDX-FileCopyrightText: Copyright (c) 2022-2023 The go-mail Authors
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Package log implements a logger interface that can be used within the go-mail package
|
|
package log
|
|
|
|
const (
|
|
DirServerToClient Direction = iota // Server to Client communication
|
|
DirClientToServer // Client to Server communication
|
|
)
|
|
|
|
// Direction is a type wrapper for the direction a debug log message goes
|
|
type Direction int
|
|
|
|
// Log represents a log message type that holds a log Direction, a Format string
|
|
// and a slice of Messages
|
|
type Log struct {
|
|
Direction Direction
|
|
Format string
|
|
Messages []interface{}
|
|
}
|
|
|
|
// Logger is the log interface for go-mail
|
|
type Logger interface {
|
|
Debugf(Log)
|
|
Infof(Log)
|
|
Warnf(Log)
|
|
Errorf(Log)
|
|
}
|