diff --git a/elstat/adapters.py b/elstat/adapters.py index dceb16d..812aa7b 100644 --- a/elstat/adapters.py +++ b/elstat/adapters.py @@ -66,12 +66,13 @@ class PingAdapter(Adapter): else: latency = 0 - worker.log.info(f'alive={alive} latency={latency}ms') - if alive: # we dont need to keep sending err_msg on alive scenarios return cls._construct(alive, latency) + # only log on errors + worker.log.info(f'alive={alive} latency={latency}ms') + err = PING_ERROR_RGX.search(out) err_msg = err.group(2) if not alive and err else 'packet lost' @@ -110,9 +111,11 @@ class HttpAdapter(Adapter): # drop latency to 0 to signal a non-success latency = latency if succ else 0 - worker.log.info(f'status={resp.status} latency={latency}ms') - if not succ: + # only log on errors + worker.log.info(f'status={resp.status} latency={latency}ms') + + # construct error message from http error code status_phrase = cls.get_phrase(resp.status) err_str = f'http status {resp.status} - {status_phrase}' return cls._construct(succ, latency, err_str)