From 471765348983ae4b0291cf223d24ec897be366c5 Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 17:47:32 +0100 Subject: [PATCH 1/6] Configure logging format --- gitopscli/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitopscli/__main__.py b/gitopscli/__main__.py index 3c21fb67..2fd21408 100644 --- a/gitopscli/__main__.py +++ b/gitopscli/__main__.py @@ -10,8 +10,9 @@ def main(): - logging.basicConfig(level=logging.INFO) - + logging.basicConfig(level=logging.INFO, + format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M') args = create_cli() if args.command == "deploy": From a7a8aa5921178ce30bd39846a3f1aad791aff9a0 Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 17:50:34 +0100 Subject: [PATCH 2/6] Fix linting --- gitopscli/__main__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitopscli/__main__.py b/gitopscli/__main__.py index 2fd21408..42261824 100644 --- a/gitopscli/__main__.py +++ b/gitopscli/__main__.py @@ -10,9 +10,9 @@ def main(): - logging.basicConfig(level=logging.INFO, - format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - datefmt='%m-%d %H:%M') + logging.basicConfig( + level=logging.INFO, format="%(asctime)s %(name)-12s %(levelname)-8s %(message)s", datefmt="%m-%d %H:%M" + ) args = create_cli() if args.command == "deploy": From 88eed91dec84c50fdca3d788a478b54d88481ada Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 18:02:27 +0100 Subject: [PATCH 3/6] Improve logging messages and format --- gitopscli/__main__.py | 2 +- gitopscli/commands/create_preview.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitopscli/__main__.py b/gitopscli/__main__.py index 42261824..168e5c8c 100644 --- a/gitopscli/__main__.py +++ b/gitopscli/__main__.py @@ -11,7 +11,7 @@ def main(): logging.basicConfig( - level=logging.INFO, format="%(asctime)s %(name)-12s %(levelname)-8s %(message)s", datefmt="%m-%d %H:%M" + level=logging.INFO, format="%(asctime)s %(levelname)-8s %(funcName)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S" ) args = create_cli() diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index 0dc14391..4b00d1e0 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -44,9 +44,9 @@ def create_preview_command( ) apps_git.checkout(branch) - logging.info("App repo %s checkout successfull", branch) + logging.info("App repo branch %s checkout successful", branch) shortened_branch_hash = hashlib.sha256(branch).hexdigest()[:8] - logging.info("Hashed branch %s to hash %s", branch, shortened_branch_hash) + logging.info("Hashed branch %s to hash: %s", branch, shortened_branch_hash) gitops_config = GitOpsConfig(apps_git.get_full_file_path(".gitops.config.yaml")) logging.info("Read GitOpsConfig: %s", gitops_config) @@ -62,7 +62,7 @@ def create_preview_command( root_tmp_dir, ) root_git.checkout("master") - logging.info("Config repo master checkout successful") + logging.info("Config repo branch master checkout successful") root_git.new_branch(branch) logging.info("Created branch %s in config repo", branch) preview_template_folder_name = ".preview-templates/" + gitops_config.application_name From da1624ed349cfe5c7982536f24b0bd16dca157dd Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 18:26:10 +0100 Subject: [PATCH 4/6] Simplify log format --- gitopscli/__main__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gitopscli/__main__.py b/gitopscli/__main__.py index 168e5c8c..1e25157f 100644 --- a/gitopscli/__main__.py +++ b/gitopscli/__main__.py @@ -10,9 +10,7 @@ def main(): - logging.basicConfig( - level=logging.INFO, format="%(asctime)s %(levelname)-8s %(funcName)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S" - ) + logging.basicConfig(level=logging.INFO, format="%(levelname)-2s %(funcName)s: %(message)s") args = create_cli() if args.command == "deploy": From 73452e58b2d3213001892ce0a6f019dbaace325a Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 18:33:22 +0100 Subject: [PATCH 5/6] Improve preview log msgs --- gitopscli/commands/create_preview.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index a0c98679..4b65b7dd 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -92,13 +92,12 @@ def create_preview_command( root_git.push(branch) logging.info("Pushed branch %s", branch) pr_comment_text = f""" -Preview created successfully. Access it [here](https://{route_host}). +Preview created successfully. Access it here: https://{route_host}. """ logging.info( - "Creating PullRequest comment for pr with id %s and parentComment with id %s and content: %s", + "Creating PullRequest comment for pr with id %s and content: %s", pr_id, - pr_comment_text, - parent_id, + pr_comment_text ) apps_git.add_pull_request_comment(pr_id, pr_comment_text, parent_id) finally: From ce8b9a96623837313ab638bc975b5231c9f24dc0 Mon Sep 17 00:00:00 2001 From: Joachim Prinzbach Date: Sat, 8 Feb 2020 18:34:22 +0100 Subject: [PATCH 6/6] Reformat --- gitopscli/commands/create_preview.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index 4b65b7dd..454fe7a4 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -94,11 +94,7 @@ def create_preview_command( pr_comment_text = f""" Preview created successfully. Access it here: https://{route_host}. """ - logging.info( - "Creating PullRequest comment for pr with id %s and content: %s", - pr_id, - pr_comment_text - ) + logging.info("Creating PullRequest comment for pr with id %s and content: %s", pr_id, pr_comment_text) apps_git.add_pull_request_comment(pr_id, pr_comment_text, parent_id) finally: shutil.rmtree(apps_tmp_dir, ignore_errors=True)