Skip to content

Commit a6e42ca

Browse files
committed
adding standard logging
1 parent 35b0da2 commit a6e42ca

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

watcher.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
import logging
77

88
# this monitors your kiln stats every N seconds
9-
# if there are bad_check_limit failures, an alert is sent to a slack channel
9+
# if X checks fail, an alert is sent to a slack channel
1010
# configure an incoming web hook on the slack channel
1111
# set slack_hook_url to that
1212

13+
logging.basicConfig(level=logging.INFO)
1314
log = logging.getLogger(__name__)
1415

1516
class Watcher(object):
@@ -31,30 +32,30 @@ def get_stats(self):
3132
return {}
3233

3334
def send_alert(self,msg):
34-
log.error("ERR sending alert: %s" % msg)
35+
log.error("sending alert: %s" % msg)
3536
try:
3637
r = requests.post(self.slack_hook_url, json={'text': msg })
3738
except:
3839
pass
3940

4041
def has_errors(self):
4142
if 'time' not in self.stats:
42-
log.error("ERR no data")
43+
log.error("no data")
4344
return True
4445
if 'err' in self.stats:
4546
if abs(self.stats['err']) > self.temp_error_limit:
46-
log.error("ERR temp out of whack %0.2f" % self.stats['err'])
47+
log.error("temp out of whack %0.2f" % self.stats['err'])
4748
return True
4849
return False
4950

5051
def run(self):
51-
log.info("OK started watching %s" % self.kiln_url)
52+
log.info("started watching %s" % self.kiln_url)
5253
while(True):
5354
self.stats = self.get_stats()
5455
if self.has_errors():
5556
self.bad_checks = self.bad_checks + 1
5657
else:
57-
log.info("OK %s" % datetime.datetime.now())
58+
log.info("%s" % datetime.datetime.now())
5859

5960
if self.bad_checks >= self.bad_check_limit:
6061
msg = "error kiln needs help. %s" % json.dumps(self.stats,indent=2, sort_keys=True)

0 commit comments

Comments
 (0)