aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-29 13:20:13 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-29 13:20:13 +0000
commite1226f14e99eb15abf7813957a12ee4532d6f991 (patch)
tree279e012386b30bb6f9c0402ee922a1f1dff7b12e
parent.pylintrc: disable more stupid warnings (diff)
downloadcmake-common-e1226f14e99eb15abf7813957a12ee4532d6f991.tar.gz
cmake-common-e1226f14e99eb15abf7813957a12ee4532d6f991.zip
clang-format.py: fix timestamps in logs
-rwxr-xr-xtools/clang-format.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/clang-format.py b/tools/clang-format.py
index 65321d2..2f64a5e 100755
--- a/tools/clang-format.py
+++ b/tools/clang-format.py
@@ -13,6 +13,7 @@ formatting the files in-place.
'''
import argparse
+from contextlib import contextmanager
import difflib
import logging
import os.path
@@ -20,10 +21,17 @@ import subprocess
import sys
+@contextmanager
def _setup_logging():
logging.basicConfig(
format='%(asctime)s | %(levelname)s | %(message)s',
+ datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO)
+ try:
+ yield
+ except Exception as e:
+ logging.exception(e)
+ raise
def _run_executable(cmd_line):
@@ -132,13 +140,9 @@ def _parse_args(argv=None):
def main(argv=None):
- _setup_logging()
- try:
+ with _setup_logging():
args = _parse_args(argv)
_process_cpp_files(args)
- except Exception as e:
- logging.exception(e)
- raise
if __name__ == '__main__':