mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
maillog: Introduce a special-purpose mail logging package
The default INFO logs are more oriented towards debugging and can be a bit too verbose when looking for high-level information. This patch introduces a new "maillog" package, used to log messages of particular relevance to mail transmission at a higher level.
This commit is contained in:
22
chasquid.go
22
chasquid.go
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"blitiri.com.ar/go/chasquid/internal/config"
|
||||
"blitiri.com.ar/go/chasquid/internal/courier"
|
||||
"blitiri.com.ar/go/chasquid/internal/maillog"
|
||||
"blitiri.com.ar/go/chasquid/internal/normalize"
|
||||
"blitiri.com.ar/go/chasquid/internal/smtpsrv"
|
||||
"blitiri.com.ar/go/chasquid/internal/systemd"
|
||||
@@ -44,7 +45,7 @@ func main() {
|
||||
|
||||
conf, err := config.Load(*configDir + "/chasquid.conf")
|
||||
if err != nil {
|
||||
glog.Fatalf("Error reading config")
|
||||
glog.Fatalf("Error reading config: %v", err)
|
||||
}
|
||||
config.LogConfig(conf)
|
||||
|
||||
@@ -55,6 +56,8 @@ func main() {
|
||||
// fixes the point of reference.
|
||||
os.Chdir(*configDir)
|
||||
|
||||
initMailLog(conf.MailLogPath)
|
||||
|
||||
if conf.MonitoringAddress != "" {
|
||||
launchMonitoringServer(conf.MonitoringAddress)
|
||||
}
|
||||
@@ -149,6 +152,23 @@ func loadAddresses(srv *smtpsrv.Server, addrs []string, ls []net.Listener, mode
|
||||
}
|
||||
}
|
||||
|
||||
func initMailLog(path string) {
|
||||
var err error
|
||||
|
||||
if path == "<syslog>" {
|
||||
maillog.Default, err = maillog.NewSyslog()
|
||||
} else {
|
||||
os.MkdirAll(filepath.Dir(path), 0775)
|
||||
var f *os.File
|
||||
f, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
|
||||
maillog.Default = maillog.New(f)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Error opening mail log: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to load a single domain configuration into the server.
|
||||
func loadDomain(name, dir string, s *smtpsrv.Server) {
|
||||
glog.Infof(" %s", name)
|
||||
|
||||
Reference in New Issue
Block a user