Reduce logger verbosity
This commit is contained in:
parent
f11b9b1d93
commit
e6a59019c5
3 changed files with 12 additions and 12 deletions
|
@ -37,7 +37,7 @@ $ make run
|
||||||
- [X] Add options to the server
|
- [X] Add options to the server
|
||||||
- [X] Pass logger to the server through an option
|
- [X] Pass logger to the server through an option
|
||||||
- [X] Configure logger through config (levels and such)
|
- [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 a configurable template to fill with each notification
|
||||||
- [ ] Create different message systems to use with the bot
|
- [ ] Create different message systems to use with the bot
|
||||||
- [X] Telegram
|
- [X] Telegram
|
||||||
|
|
|
@ -79,7 +79,7 @@ func New(options ...Option) (*Server, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(srv.workers) == 0 {
|
if len(srv.workers) == 0 {
|
||||||
srv.Logger.Info("creating server workers")
|
srv.Logger.Debug("creating server workers")
|
||||||
|
|
||||||
srv.workers = []Worker{NewSimpleWorker(srv)}
|
srv.workers = []Worker{NewSimpleWorker(srv)}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ func (s *Server) Start() {
|
||||||
for _, worker := range s.workers {
|
for _, worker := range s.workers {
|
||||||
worker.Start()
|
worker.Start()
|
||||||
}
|
}
|
||||||
s.Logger.Info("server started", "workers", len(s.workers))
|
s.Logger.Debug("server started", "workers", len(s.workers))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Stop() {
|
func (s *Server) Stop() {
|
||||||
|
@ -100,7 +100,7 @@ func (s *Server) Stop() {
|
||||||
for _, worker := range s.workers {
|
for _, worker := range s.workers {
|
||||||
worker.Stop()
|
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 {
|
func (s *Server) Notify(birthday *model.Birthday) error {
|
||||||
|
|
|
@ -30,16 +30,16 @@ func NewSimpleWorker(server *Server) *SimpleWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SimpleWorker) Start() {
|
func (w *SimpleWorker) Start() {
|
||||||
w.logger.Info("starting worker")
|
w.logger.Debug("starting worker")
|
||||||
go w.run()
|
go w.run()
|
||||||
w.logger.Info("worker started")
|
w.logger.Debug("worker started")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SimpleWorker) Stop() {
|
func (w *SimpleWorker) Stop() {
|
||||||
w.logger.Info("stopping worker")
|
w.logger.Debug("stopping worker")
|
||||||
w.stop <- true
|
w.stop <- true
|
||||||
<-w.stopped
|
<-w.stopped
|
||||||
w.logger.Info("worker stopped")
|
w.logger.Debug("worker stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SimpleWorker) notifyDay(year, month, day int) {
|
func (w *SimpleWorker) notifyDay(year, month, day int) {
|
||||||
|
@ -65,13 +65,13 @@ func (w *SimpleWorker) run() {
|
||||||
firstTick := eleven.Sub(now)
|
firstTick := eleven.Sub(now)
|
||||||
|
|
||||||
var ticker *time.Ticker
|
var ticker *time.Ticker
|
||||||
w.logger.Info("first timer tick set", "tick", firstTick)
|
w.logger.Debug("first timer tick set", "tick", firstTick)
|
||||||
select {
|
select {
|
||||||
case <-time.After(firstTick):
|
case <-time.After(firstTick):
|
||||||
ticker = time.NewTicker(24 * time.Hour)
|
ticker = time.NewTicker(24 * time.Hour)
|
||||||
w.notifyDay(eleven.Year(), int(eleven.Month()), eleven.Day())
|
w.notifyDay(eleven.Year(), int(eleven.Month()), eleven.Day())
|
||||||
case <-w.stop:
|
case <-w.stop:
|
||||||
w.logger.Info("received stop signal")
|
w.logger.Debug("received stop signal")
|
||||||
w.stopped <- true
|
w.stopped <- true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,10 @@ func (w *SimpleWorker) run() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case t := <-ticker.C:
|
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())
|
w.notifyDay(t.Year(), int(t.Month()), t.Day())
|
||||||
case <-w.stop:
|
case <-w.stop:
|
||||||
w.logger.Info("received stop signal")
|
w.logger.Debug("received stop signal")
|
||||||
w.stopped <- true
|
w.stopped <- true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue