aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjobmanager.py1
-rwxr-xr-xmain.py15
-rwxr-xr-xsettings.cfg.example41
3 files changed, 33 insertions, 24 deletions
diff --git a/jobmanager.py b/jobmanager.py
index e4cb72a..1683e2c 100755
--- a/jobmanager.py
+++ b/jobmanager.py
@@ -61,6 +61,7 @@ class JobManager:
if not thisJob.onFailure():
emailWorks = False
else:
+ logging.info("Skipping notification of failure for " + thisJob.getName())
lastRunStatus.markFailedNoNotify()
else:
#Successful Run
diff --git a/main.py b/main.py
index 461a864..49bb5bb 100755
--- a/main.py
+++ b/main.py
@@ -23,15 +23,14 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check your stuff.")
parser.add_argument('-m', '--mode', choices=['daemon', 'cron'], required=True, help='The mode the application will run it.')
parser.add_argument('-c', '--crontime', choices=['minute', 'hour', 'day', 'day_noon'], help='When in cron mode, the increment of cron.')
- parser.add_argument('-v', action="store_true", help="Print verbose debugging information to stderr")
+ parser.add_argument('-v', action="store_true", help="Print verbose debugging information to the logfile")
+ parser.add_argument('-d', action="store_true", help="Print verbose debugging information to stderr")
parser.add_argument('--nomail', action="store_true", help="Do everything except sending email")
args = parser.parse_args()
config = ConfigParser.ConfigParser()
configfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'settings.cfg')
- if args.v:
- print "[Pre-Logging] Reading config from", configfile
config.read(configfile)
if args.nomail:
config.set('email', 'nomail', "True")
@@ -53,10 +52,18 @@ if __name__ == "__main__":
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.CRITICAL)
- logging.basicConfig(format="%(asctime)s:%(levelname)s: %(message)s")
+ log_formatter = logging.Formatter(fmt="%(asctime)s:%(levelname)s: %(message)s")
log = logging.getLogger()
if args.v:
log.setLevel(logging.DEBUG)
+ log_file_handler = logging.FileHandler(config.get('general', 'logfile'))
+ log_file_handler.setFormatter(log_formatter)
+ log.addHandler(log_file_handler)
+ if args.d:
+ log.setLevel(logging.DEBUG)
+ log_stderr_handler = logging.StreamHandler()
+ log_stderr_handler.setFormatter(log_formatter)
+ log.addHandler(log_stderr_handler)
if args.mode == 'daemon':
log.info("Starting up daemon")
diff --git a/settings.cfg.example b/settings.cfg.example
index cd99db9..19b60d3 100755
--- a/settings.cfg.example
+++ b/settings.cfg.example
@@ -1,21 +1,22 @@
-[general]
-servername=uniqueservername
-alertcontact=youremail@example.com
-statefile=/fully/qualified/path/jobrunhistory.db
-
-[email]
-nomail=False
-user=agmailaccountyoucreate@gmail.com
-pass=yourpassword
-smtpserver=smtp.gmail.com
-smtpport=587
-imapserver=imap.gmail.com
-#I create a filter that automatically deletes my sent messages.
-# This way, anyone who hacks the account only sees the last 30 days of messages I've sent
-ideletesentmessagesautomatically=True
-#If set, append a random number to prevent gmail threading
-bustgmailthreading=False
-
-[peers]
-peer1=http://someserver.com:5000,admin@someserverbackup.com
+[general]
+servername=uniqueservername
+alertcontact=youremail@example.com
+logfile=/fully/qualified/path/logfile.log
+statefile=/fully/qualified/path/jobrunhistory.db
+
+[email]
+nomail=False
+user=agmailaccountyoucreate@gmail.com
+pass=yourpassword
+smtpserver=smtp.gmail.com
+smtpport=587
+imapserver=imap.gmail.com
+#I create a filter that automatically deletes my sent messages.
+# This way, anyone who hacks the account only sees the last 30 days of messages I've sent
+ideletesentmessagesautomatically=True
+#If set, append a random number to prevent gmail threading
+bustgmailthreading=False
+
+[peers]
+peer1=http://someserver.com:5000,admin@someserverbackup.com
peer2=http://someotherserver.com:5000,admin@someotherserver.com \ No newline at end of file