1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-19 02:27:03 +00:00

Logging and unit test changes

Logging methods were renamed so they don't trigger go-vet warnings for
error() and Error() formatting.

Unit tests were updated to use new github.com/stretchr repo (was renamed
from stretchrcom)

Missing methods were added to Message mock object.
This commit is contained in:
James Hillyerd
2013-09-13 14:06:57 -07:00
parent f50061ac82
commit 2e78e4e6f7
16 changed files with 180 additions and 171 deletions

View File

@@ -87,7 +87,7 @@ func main() {
if *pidfile != "none" {
pidf, err := os.Create(*pidfile)
if err != nil {
log.Error("Failed to create %v: %v", *pidfile, err)
log.LogError("Failed to create %v: %v", *pidfile, err)
os.Exit(1)
}
defer pidf.Close()
@@ -119,13 +119,13 @@ func openLogFile() error {
return fmt.Errorf("Failed to create %v: %v\n", *logfile, err)
}
golog.SetOutput(logf)
log.Trace("Opened new logfile")
log.LogTrace("Opened new logfile")
return nil
}
// closeLogFile closes the current logfile
func closeLogFile() error {
log.Trace("Closing logfile")
log.LogTrace("Closing logfile")
return logf.Close()
}
@@ -137,21 +137,21 @@ func signalProcessor(c <-chan os.Signal) {
case syscall.SIGHUP:
// Rotate logs if configured
if logf != nil {
log.Info("Recieved SIGHUP, cycling logfile")
log.LogInfo("Recieved SIGHUP, cycling logfile")
closeLogFile()
openLogFile()
} else {
log.Info("Ignoring SIGHUP, logfile not configured")
log.LogInfo("Ignoring SIGHUP, logfile not configured")
}
case syscall.SIGTERM:
// Initiate shutdown
log.Info("Received SIGTERM, shutting down")
log.LogInfo("Received SIGTERM, shutting down")
go timedExit()
web.Stop()
if smtpServer != nil {
smtpServer.Stop()
} else {
log.Error("smtpServer was nil during shutdown")
log.LogError("smtpServer was nil during shutdown")
}
}
}
@@ -160,7 +160,7 @@ func signalProcessor(c <-chan os.Signal) {
// timedExit is called as a goroutine during shutdown, it will force an exit after 15 seconds
func timedExit() {
time.Sleep(15 * time.Second)
log.Error("Inbucket clean shutdown timed out, forcing exit")
log.LogError("Inbucket clean shutdown timed out, forcing exit")
os.Exit(0)
}