Reduce logger verbosity

This commit is contained in:
Miguel de la Cruz 2023-07-10 19:58:55 +02:00
parent f11b9b1d93
commit e6a59019c5
3 changed files with 12 additions and 12 deletions

View file

@ -37,7 +37,7 @@ $ make run
- [X] Add options to the server
- [X] Pass logger to the server through an option
- [X] Configure logger through config (levels and such)
- [ ] Reduce logger verbosity (through levels)
- [X] Reduce logger verbosity (through levels)
- [ ] Create a configurable template to fill with each notification
- [ ] Create different message systems to use with the bot
- [X] Telegram

View file

@ -79,7 +79,7 @@ func New(options ...Option) (*Server, error) {
}
if len(srv.workers) == 0 {
srv.Logger.Info("creating server workers")
srv.Logger.Debug("creating server workers")
srv.workers = []Worker{NewSimpleWorker(srv)}
}
@ -92,7 +92,7 @@ func (s *Server) Start() {
for _, worker := range s.workers {
worker.Start()
}
s.Logger.Info("server started", "workers", len(s.workers))
s.Logger.Debug("server started", "workers", len(s.workers))
}
func (s *Server) Stop() {
@ -100,7 +100,7 @@ func (s *Server) Stop() {
for _, worker := range s.workers {
worker.Stop()
}
s.Logger.Info("server stopped", "workers", len(s.workers))
s.Logger.Debug("server stopped", "workers", len(s.workers))
}
func (s *Server) Notify(birthday *model.Birthday) error {

View file

@ -30,16 +30,16 @@ func NewSimpleWorker(server *Server) *SimpleWorker {
}
func (w *SimpleWorker) Start() {
w.logger.Info("starting worker")
w.logger.Debug("starting worker")
go w.run()
w.logger.Info("worker started")
w.logger.Debug("worker started")
}
func (w *SimpleWorker) Stop() {
w.logger.Info("stopping worker")
w.logger.Debug("stopping worker")
w.stop <- true
<-w.stopped
w.logger.Info("worker stopped")
w.logger.Debug("worker stopped")
}
func (w *SimpleWorker) notifyDay(year, month, day int) {
@ -65,13 +65,13 @@ func (w *SimpleWorker) run() {
firstTick := eleven.Sub(now)
var ticker *time.Ticker
w.logger.Info("first timer tick set", "tick", firstTick)
w.logger.Debug("first timer tick set", "tick", firstTick)
select {
case <-time.After(firstTick):
ticker = time.NewTicker(24 * time.Hour)
w.notifyDay(eleven.Year(), int(eleven.Month()), eleven.Day())
case <-w.stop:
w.logger.Info("received stop signal")
w.logger.Debug("received stop signal")
w.stopped <- true
return
}
@ -79,10 +79,10 @@ func (w *SimpleWorker) run() {
for {
select {
case t := <-ticker.C:
w.logger.Info("ticker ticked for worker", "tick", t)
w.logger.Debug("ticker ticked for worker", "tick", t)
w.notifyDay(t.Year(), int(t.Month()), t.Day())
case <-w.stop:
w.logger.Info("received stop signal")
w.logger.Debug("received stop signal")
w.stopped <- true
return
}