From 33cfbbf1530a763244123c99f550b9410a7d9449 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Thu, 22 Jun 2023 19:48:17 +0530 Subject: [PATCH] chore: enable print logs for background workers when in DEBUG mode (#1357) --- apiserver/plane/bgtasks/analytic_plot_export.py | 4 +++- apiserver/plane/bgtasks/email_verification_task.py | 3 +++ apiserver/plane/bgtasks/forgot_password_task.py | 3 +++ apiserver/plane/bgtasks/importer_task.py | 3 +++ apiserver/plane/bgtasks/issue_activites_task.py | 3 +++ apiserver/plane/bgtasks/magic_link_code_task.py | 3 +++ apiserver/plane/bgtasks/project_invitation_task.py | 3 +++ apiserver/plane/bgtasks/user_welcome_task.py | 3 +++ apiserver/plane/bgtasks/workspace_invitation_task.py | 3 +++ 9 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/bgtasks/analytic_plot_export.py b/apiserver/plane/bgtasks/analytic_plot_export.py index 37362416f..27b625445 100644 --- a/apiserver/plane/bgtasks/analytic_plot_export.py +++ b/apiserver/plane/bgtasks/analytic_plot_export.py @@ -169,6 +169,8 @@ def analytic_export_task(email, data, slug): msg.send(fail_silently=False) except Exception as e: - print(e) + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/email_verification_task.py b/apiserver/plane/bgtasks/email_verification_task.py index 89551044b..93b15c425 100644 --- a/apiserver/plane/bgtasks/email_verification_task.py +++ b/apiserver/plane/bgtasks/email_verification_task.py @@ -39,5 +39,8 @@ def email_verification(first_name, email, token, current_site): msg.send() return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/forgot_password_task.py b/apiserver/plane/bgtasks/forgot_password_task.py index 687e4f976..93283dfd5 100644 --- a/apiserver/plane/bgtasks/forgot_password_task.py +++ b/apiserver/plane/bgtasks/forgot_password_task.py @@ -37,5 +37,8 @@ def forgot_password(first_name, email, uidb64, token, current_site): msg.send() return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/importer_task.py b/apiserver/plane/bgtasks/importer_task.py index 85ac1c89b..757ef601b 100644 --- a/apiserver/plane/bgtasks/importer_task.py +++ b/apiserver/plane/bgtasks/importer_task.py @@ -175,5 +175,8 @@ def service_importer(service, importer_id): importer = Importer.objects.get(pk=importer_id) importer.status = "failed" importer.save() + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index b1096e30b..5865a5982 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -1006,5 +1006,8 @@ def issue_activity( ) return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/magic_link_code_task.py b/apiserver/plane/bgtasks/magic_link_code_task.py index 29851c435..91cc461bb 100644 --- a/apiserver/plane/bgtasks/magic_link_code_task.py +++ b/apiserver/plane/bgtasks/magic_link_code_task.py @@ -31,4 +31,7 @@ def magic_link(email, key, token, current_site): return except Exception as e: capture_exception(e) + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) return diff --git a/apiserver/plane/bgtasks/project_invitation_task.py b/apiserver/plane/bgtasks/project_invitation_task.py index 7f1125f80..8b8ef6e48 100644 --- a/apiserver/plane/bgtasks/project_invitation_task.py +++ b/apiserver/plane/bgtasks/project_invitation_task.py @@ -50,5 +50,8 @@ def project_invitation(email, project_id, token, current_site): except (Project.DoesNotExist, ProjectMemberInvite.DoesNotExist) as e: return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/user_welcome_task.py b/apiserver/plane/bgtasks/user_welcome_task.py index bea2ee33d..33f4b5686 100644 --- a/apiserver/plane/bgtasks/user_welcome_task.py +++ b/apiserver/plane/bgtasks/user_welcome_task.py @@ -29,5 +29,8 @@ def send_welcome_slack(user_id, created, message): print(f"Got an error: {e.response['error']}") return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return diff --git a/apiserver/plane/bgtasks/workspace_invitation_task.py b/apiserver/plane/bgtasks/workspace_invitation_task.py index 7b2bada0a..d84a0b414 100644 --- a/apiserver/plane/bgtasks/workspace_invitation_task.py +++ b/apiserver/plane/bgtasks/workspace_invitation_task.py @@ -66,5 +66,8 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor): except (Workspace.DoesNotExist, WorkspaceMemberInvite.DoesNotExist) as e: return except Exception as e: + # Print logs if in DEBUG mode + if settings.DEBUG: + print(e) capture_exception(e) return