Add logging.

master
Simon Quigley 5 years ago
parent 9068136a8e
commit f44618824b

@ -16,6 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import logging as log
import sqlite3
from modules.jenkins import JenkinsModule
@ -52,9 +53,11 @@ def main(module):
run.append(module.sqlite_setup())
run.append(module.sqlite_add())
run.append(module.sqlite_time_range(days=10))
log.debug("Commands to be ran: " + str(run))
# Use --db-location to pass to sqlite
print(sqlite_run(run, db=args.db_location, return_output=True))
log.info("Running SQLite commands")
log.debug(sqlite_run(run, db=args.db_location, return_output=True))
if __name__ == "__main__":
@ -62,7 +65,19 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--db-location", type=str, default=":memory:",
help="Specify the location for the SQLite database")
parser.add_argument("--log", type=str, default="WARNING",
help="Default logging level")
args = parser.parse_args()
# Ensure the logging level is set properly
num_level = getattr(log, args.log.upper(), None)
if not isinstance(num_level, int):
raise ValueError("Invalid log level: %s" % loglevel)
# Fully configure the logger
log.basicConfig(format="%(asctime)s\t%(levelname)s\t%(message)s",
level=num_level)
for module in ENABLED_MODULES:
log.info("Working on %s..." % module.__name__)
main(module)

Loading…
Cancel
Save