From e6a59019c554622c88cf0d9203e378ace655d81e Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Mon, 10 Jul 2023 19:58:55 +0200 Subject: [PATCH] Reduce logger verbosity --- README.md | 2 +- server/server.go | 6 +++--- server/worker.go | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index de3302f..6dd0e32 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/server/server.go b/server/server.go index 955953e..de70304 100644 --- a/server/server.go +++ b/server/server.go @@ -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 { diff --git a/server/worker.go b/server/worker.go index 40caf4f..1676454 100644 --- a/server/worker.go +++ b/server/worker.go @@ -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 }