diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-29 13:20:13 +0000 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-29 13:20:13 +0000 |
commit | e1226f14e99eb15abf7813957a12ee4532d6f991 (patch) | |
tree | 279e012386b30bb6f9c0402ee922a1f1dff7b12e | |
parent | .pylintrc: disable more stupid warnings (diff) | |
download | cmake-common-e1226f14e99eb15abf7813957a12ee4532d6f991.tar.gz cmake-common-e1226f14e99eb15abf7813957a12ee4532d6f991.zip |
clang-format.py: fix timestamps in logs
-rwxr-xr-x | tools/clang-format.py | 14 |
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__': |