1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00
Files
go-chasquid-smtp/internal/trace/trace.go
Alberto Bertogli 77d547288f Implement couriers
This patch introduces the couriers, which the queue uses to deliver mail.

We have a local courier (using procmail), a remote courier (uses SMTP), and a
router courier that decides which of the two to use based on a list of local
domains.

There are still a few things pending, but they all have their basic
functionality working and tested.
2015-11-13 03:41:06 +00:00

61 lines
1.1 KiB
Go

// Package trace extends golang.org/x/net/trace.
package trace
import (
"fmt"
"github.com/golang/glog"
nettrace "golang.org/x/net/trace"
)
type Trace struct {
family string
title string
t nettrace.Trace
}
func New(family, title string) *Trace {
return &Trace{family, title, nettrace.New(family, title)}
}
func (t *Trace) LazyPrintf(format string, a ...interface{}) {
t.t.LazyPrintf(format, a...)
if glog.V(2) {
msg := fmt.Sprintf("%p %s %s: %+q", t, t.family, t.title,
fmt.Sprintf(format, a...))
glog.InfoDepth(1, msg)
}
}
func (t *Trace) SetError() {
t.t.SetError()
}
func (t *Trace) Errorf(format string, a ...interface{}) error {
err := fmt.Errorf(format, a...)
t.t.SetError()
t.t.LazyPrintf("error: %v", err)
if glog.V(2) {
msg := fmt.Sprintf("%p %s %s: error: %v", t, t.family, t.title, err)
glog.InfoDepth(1, msg)
}
return err
}
func (t *Trace) Error(err error) error {
t.t.SetError()
t.t.LazyPrintf("error: %v", err)
if glog.V(2) {
msg := fmt.Sprintf("%p %s %s: error: %v", t, t.family, t.title, err)
glog.InfoDepth(1, msg)
}
return err
}
func (t *Trace) Finish() {
t.t.Finish()
}