mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: logging
This commit is contained in:
parent
4ce75c2acb
commit
99e50b1062
@ -33,6 +33,7 @@ func NewMiscService(userService IUserService, summaryService ISummaryService, ke
|
||||
}
|
||||
|
||||
func (srv *MiscService) ScheduleCountTotalTime() {
|
||||
logbuch.Info("scheduling total time counting")
|
||||
if _, err := srv.queueDefault.DispatchEvery(srv.CountTotalTime, 1*time.Hour); err != nil {
|
||||
config.Log().Error("failed to schedule user counting jobs, %v", err)
|
||||
}
|
||||
@ -41,7 +42,7 @@ func (srv *MiscService) ScheduleCountTotalTime() {
|
||||
func (srv *MiscService) CountTotalTime() {
|
||||
users, err := srv.userService.GetAll()
|
||||
if err != nil {
|
||||
logbuch.Error("failed to fetch users for time counting, %v", err)
|
||||
config.Log().Error("failed to fetch users for time counting, %v", err)
|
||||
}
|
||||
|
||||
var totalTime time.Duration = 0
|
||||
@ -65,14 +66,14 @@ func (srv *MiscService) CountTotalTime() {
|
||||
Key: config.KeyLatestTotalTime,
|
||||
Value: totalTime.String(),
|
||||
}); err != nil {
|
||||
logbuch.Error("failed to save total time count: %v", err)
|
||||
config.Log().Error("failed to save total time count: %v", err)
|
||||
}
|
||||
|
||||
if err := srv.keyValueService.PutString(&models.KeyStringValue{
|
||||
Key: config.KeyLatestTotalUsers,
|
||||
Value: strconv.Itoa(len(users)),
|
||||
}); err != nil {
|
||||
logbuch.Error("failed to save total users count: %v", err)
|
||||
config.Log().Error("failed to save total users count: %v", err)
|
||||
}
|
||||
} else {
|
||||
config.Log().Error("waiting for user counting jobs timed out")
|
||||
|
Loading…
Reference in New Issue
Block a user