From 40f21fc7e044853a9f33858b2464f0d43bf0f398 Mon Sep 17 00:00:00 2001 From: jowj Date: Sun, 16 Sep 2018 20:58:09 -0500 Subject: [PATCH] Update arke.py to use logging() instead of manually creating a table and printing it. --- arke.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arke.py b/arke.py index 2152853..a2a9c2d 100644 --- a/arke.py +++ b/arke.py @@ -1,15 +1,20 @@ -import requests, arkevars, json +import requests, arkevars, json, logging + +FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s" +logging.basicConfig(format=FORMAT) +logging.basicConfig(level=logging.DEBUG) +logger = logging.getLogger("arke") def gather_JsonData(monitoringtargets): responseTable = {} for target in monitoringtargets: try: statuscode = requests.get(target).status_code - responseTable[target] = statuscode + logger.info(f"target: {target} statuscode: {statuscode}") # prints the int of the status code. Find more at httpstatusrappers.com :) except requests.ConnectionError: - responseTable[target] = "Failed to connect." + logger.info(f"target: {target} ERROR: Failure to connect.") return responseTable