summaryrefslogtreecommitdiff
path: root/jobs.go
diff options
context:
space:
mode:
authorJan Dittberner <jan@dittberner.info>2017-04-22 00:06:16 +0200
committerJan Dittberner <jan@dittberner.info>2017-04-22 00:14:38 +0200
commit5a449926f417f75acff415d1a359571d86be0983 (patch)
tree0457a5ab88841156e379c977442a6e87e64e3419 /jobs.go
parentfd0a8ed972f6b9327d118292b46ab5c601a48ac3 (diff)
downloadcacert-boardvoting-5a449926f417f75acff415d1a359571d86be0983.tar.gz
cacert-boardvoting-5a449926f417f75acff415d1a359571d86be0983.tar.xz
cacert-boardvoting-5a449926f417f75acff415d1a359571d86be0983.zip
Use loggo for logging0.1.0
Diffstat (limited to 'jobs.go')
-rw-r--r--jobs.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/jobs.go b/jobs.go
index 2535ef1..8d0bf13 100644
--- a/jobs.go
+++ b/jobs.go
@@ -22,19 +22,19 @@ func JobScheduler(quitChannel chan int) {
JobIdCloseDecisions: NewCloseDecisionsJob(),
JobIdRemindVotersJob: NewRemindVotersJob(),
}
- logger.Println("INFO started job scheduler")
+ logger.Infof("started job scheduler")
for {
select {
case jobId := <-rescheduleChannel:
job := jobs[jobId]
- logger.Println("INFO reschedule job", job)
+ logger.Infof("reschedule job %s", job)
job.Schedule()
case <-quitChannel:
for _, job := range jobs {
job.Stop()
}
- logger.Println("INFO stop job scheduler")
+ logger.Infof("stop job scheduler")
return
}
}
@@ -54,7 +54,7 @@ func (j *CloseDecisionsJob) Schedule() {
var nextDue *time.Time
nextDue, err := GetNextPendingDecisionDue()
if err != nil {
- logger.Fatal("ERROR Could not get next pending due date")
+ logger.Errorf("Could not get next pending due date")
if j.timer != nil {
j.timer.Stop()
j.timer = nil
@@ -62,11 +62,11 @@ func (j *CloseDecisionsJob) Schedule() {
return
}
if nextDue == nil {
- logger.Println("INFO no next planned execution of CloseDecisionsJob")
+ logger.Infof("no next planned execution of CloseDecisionsJob")
j.Stop()
} else {
nextDue := nextDue.Add(time.Minute)
- logger.Println("INFO scheduling CloseDecisionsJob for", nextDue)
+ logger.Infof("scheduling CloseDecisionsJob for %s", nextDue)
when := nextDue.Sub(time.Now())
if j.timer != nil {
j.timer.Reset(when)
@@ -84,10 +84,10 @@ func (j *CloseDecisionsJob) Stop() {
}
func (j *CloseDecisionsJob) Run() {
- logger.Println("INFO running CloseDecisionsJob")
+ logger.Infof("running CloseDecisionsJob")
err := CloseDecisions()
if err != nil {
- logger.Println("ERROR closing decisions", err)
+ logger.Errorf("closing decisions %s", err)
}
rescheduleChannel <- JobIdCloseDecisions
}
@@ -109,7 +109,7 @@ func NewRemindVotersJob() *RemindVotersJob {
func (j *RemindVotersJob) Schedule() {
year, month, day := time.Now().UTC().Date()
nextExecution := time.Date(year, month, day, 0, 0, 0, 0, time.UTC).AddDate(0, 0, 3)
- logger.Println("INFO scheduling RemindVotersJob for", nextExecution)
+ logger.Infof("scheduling RemindVotersJob for %s", nextExecution)
when := nextExecution.Sub(time.Now())
if j.timer != nil {
j.timer.Reset(when)
@@ -126,19 +126,19 @@ func (j *RemindVotersJob) Stop() {
}
func (j *RemindVotersJob) Run() {
- logger.Println("INFO running RemindVotersJob")
+ logger.Infof("running RemindVotersJob")
defer func() { rescheduleChannel <- JobIdRemindVotersJob }()
voters, err := GetReminderVoters()
if err != nil {
- logger.Println("ERROR problem getting voters", err)
+ logger.Errorf("problem getting voters %s", err)
return
}
for _, voter := range *voters {
decisions, err := FindUnvotedDecisionsForVoter(&voter)
if err != nil {
- logger.Println("ERROR problem getting unvoted decisions")
+ logger.Errorf("problem getting unvoted decisions")
return
}
if len(*decisions) > 0 {