Commit 2d159deb authored by Morten Brekkevold's avatar Morten Brekkevold

add option to remove timestamps from log output

having timestamps in the log output will cause kindnavsyncdiff to trigger on
every run, even though the output is in fact the same.
parent 2459550b
......@@ -44,7 +44,7 @@ LOG = logging.getLogger('kindnavsync')
def main():
args = parse_args()
initlogging(args.debug, args.no_timestamps)
kind = get_kind_data()
LOG.debug("Fant %s utstyrsposter i Kind", len(kind))
......@@ -83,6 +83,8 @@ def parse_args():
parser.add_argument("--api-token", "-t",
help="NAV API Token")
parser.add_argument("--no-timestamps", action="store_true",
help="Don't add timestamps to log output")
args = parser.parse_args()
......@@ -94,9 +96,11 @@ def parse_args():
return args
def initlogging(debug=False):
logging.basicConfig(format="%(asctime)s [%(levelname)s] [%(name)s] "
def initlogging(debug=False, no_timestamps=False):
format = "[%(levelname)s] [%(name)s] %(message)s"
if not no_timestamps:
format = "%(asctime)s " + format
LOG.setLevel(logging.DEBUG if debug else logging.INFO)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment