2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-24 23:02:18 +08:00

Clean up log messages

Moved development purpose log messages to DEBUG level.
This commit is contained in:
Ken Hibino 2020-05-11 07:02:26 -07:00
parent cfcd19a222
commit fb38086590
7 changed files with 13 additions and 14 deletions

View File

@ -35,7 +35,7 @@ func init() {
flag.Var(&testLogLevel, "loglevel", "log level to use in testing") flag.Var(&testLogLevel, "loglevel", "log level to use in testing")
testLogger = log.NewLogger(nil) testLogger = log.NewLogger(nil)
testLogger.SetLevel(log.Level(testLogLevel)) testLogger.SetLevel(toInternalLogLevel(testLogLevel))
} }
func setup(tb testing.TB) *redis.Client { func setup(tb testing.TB) *redis.Client {

View File

@ -38,7 +38,7 @@ func newHeartbeater(l *log.Logger, b base.Broker, ss *base.ServerState, interval
} }
func (h *heartbeater) terminate() { func (h *heartbeater) terminate() {
h.logger.Info("Heartbeater shutting down...") h.logger.Debug("Heartbeater shutting down...")
// Signal the heartbeater goroutine to stop. // Signal the heartbeater goroutine to stop.
h.done <- struct{}{} h.done <- struct{}{}
} }
@ -54,7 +54,7 @@ func (h *heartbeater) start(wg *sync.WaitGroup) {
select { select {
case <-h.done: case <-h.done:
h.broker.ClearServerState(h.ss) h.broker.ClearServerState(h.ss)
h.logger.Info("Heartbeater done") h.logger.Debug("Heartbeater done")
return return
case <-time.After(h.interval): case <-time.After(h.interval):
h.beat() h.beat()

View File

@ -106,7 +106,7 @@ func newProcessor(params newProcessorParams) *processor {
// It's safe to call this method multiple times. // It's safe to call this method multiple times.
func (p *processor) stop() { func (p *processor) stop() {
p.once.Do(func() { p.once.Do(func() {
p.logger.Info("Processor shutting down...") p.logger.Debug("Processor shutting down...")
// Unblock if processor is waiting for sema token. // Unblock if processor is waiting for sema token.
close(p.abort) close(p.abort)
// Signal the processor goroutine to stop processing tasks // Signal the processor goroutine to stop processing tasks
@ -145,7 +145,7 @@ func (p *processor) start(wg *sync.WaitGroup) {
for { for {
select { select {
case <-p.done: case <-p.done:
p.logger.Info("Processor done") p.logger.Debug("Processor done")
return return
default: default:
p.exec() p.exec()

View File

@ -41,7 +41,7 @@ func newScheduler(l *log.Logger, b base.Broker, avgInterval time.Duration, qcfg
} }
func (s *scheduler) terminate() { func (s *scheduler) terminate() {
s.logger.Info("Scheduler shutting down...") s.logger.Debug("Scheduler shutting down...")
// Signal the scheduler goroutine to stop polling. // Signal the scheduler goroutine to stop polling.
s.done <- struct{}{} s.done <- struct{}{}
} }
@ -54,7 +54,7 @@ func (s *scheduler) start(wg *sync.WaitGroup) {
for { for {
select { select {
case <-s.done: case <-s.done:
s.logger.Info("Scheduler done") s.logger.Debug("Scheduler done")
return return
case <-time.After(s.avgInterval): case <-time.After(s.avgInterval):
s.exec() s.exec()

View File

@ -401,7 +401,6 @@ func (srv *Server) Stop() {
return return
} }
fmt.Println() // print newline for prettier log.
srv.logger.Info("Starting graceful shutdown") srv.logger.Info("Starting graceful shutdown")
// Note: The order of termination is important. // Note: The order of termination is important.
// Sender goroutines should be terminated before the receiver goroutines. // Sender goroutines should be terminated before the receiver goroutines.
@ -417,7 +416,7 @@ func (srv *Server) Stop() {
srv.broker.Close() srv.broker.Close()
srv.ss.SetStatus(base.StatusStopped) srv.ss.SetStatus(base.StatusStopped)
srv.logger.Info("Bye!") srv.logger.Info("Exiting")
} }
// Quiet signals the server to stop pulling new tasks off queues. // Quiet signals the server to stop pulling new tasks off queues.

View File

@ -38,7 +38,7 @@ func newSubscriber(l *log.Logger, b base.Broker, cancelations *base.Cancelations
} }
func (s *subscriber) terminate() { func (s *subscriber) terminate() {
s.logger.Info("Subscriber shutting down...") s.logger.Debug("Subscriber shutting down...")
// Signal the subscriber goroutine to stop. // Signal the subscriber goroutine to stop.
s.done <- struct{}{} s.done <- struct{}{}
} }
@ -60,7 +60,7 @@ func (s *subscriber) start(wg *sync.WaitGroup) {
case <-time.After(s.retryTimeout): case <-time.After(s.retryTimeout):
continue continue
case <-s.done: case <-s.done:
s.logger.Info("Subscriber done") s.logger.Debug("Subscriber done")
return return
} }
} }
@ -71,7 +71,7 @@ func (s *subscriber) start(wg *sync.WaitGroup) {
select { select {
case <-s.done: case <-s.done:
pubsub.Close() pubsub.Close()
s.logger.Info("Subscriber done") s.logger.Debug("Subscriber done")
return return
case msg := <-cancelCh: case msg := <-cancelCh:
cancel, ok := s.cancelations.Get(msg.Payload) cancel, ok := s.cancelations.Get(msg.Payload)

View File

@ -40,7 +40,7 @@ func newSyncer(l *log.Logger, requestsCh <-chan *syncRequest, interval time.Dura
} }
func (s *syncer) terminate() { func (s *syncer) terminate() {
s.logger.Info("Syncer shutting down...") s.logger.Debug("Syncer shutting down...")
// Signal the syncer goroutine to stop. // Signal the syncer goroutine to stop.
s.done <- struct{}{} s.done <- struct{}{}
} }
@ -59,7 +59,7 @@ func (s *syncer) start(wg *sync.WaitGroup) {
s.logger.Error(req.errMsg) s.logger.Error(req.errMsg)
} }
} }
s.logger.Info("Syncer done") s.logger.Debug("Syncer done")
return return
case req := <-s.requestsCh: case req := <-s.requestsCh:
requests = append(requests, req) requests = append(requests, req)