Skip to content

Commit

Permalink
Enhance logging to print traceback (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Dec 12, 2024
1 parent 69496c7 commit 958f1c3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jobs/ftp-poller/tasks/cas_poller_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Service to manage PAYBC services."""
import traceback
from typing import List

from flask import current_app
Expand Down Expand Up @@ -53,7 +54,7 @@ def poll_ftp(cls):
CASPollerFtpTask._post_process(sftp_client, payment_file_list)

except Exception as e: # NOQA # pylint: disable=broad-except
current_app.logger.error(e)
current_app.logger.error(f"{{error: {str(e)}, stack_trace: {traceback.format_exc()}}}")
return payment_file_list

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion jobs/ftp-poller/tasks/cgi_feeder_poller_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Service to manage PAYBC services."""
import traceback
from typing import List

from flask import current_app
Expand Down Expand Up @@ -65,7 +66,7 @@ def poll_ftp(cls):
)

except Exception as e: # NOQA # pylint: disable=broad-except
current_app.logger.error(e)
current_app.logger.error(f"{{error: {str(e)}, stack_trace: {traceback.format_exc()}}}")

@classmethod
def _move_file_to_backup(cls, sftp_client, backup_file_list):
Expand Down
3 changes: 2 additions & 1 deletion jobs/ftp-poller/tasks/eft_poller_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Service to manage EFT TDI17 files."""
import traceback
from typing import List

from flask import current_app
Expand Down Expand Up @@ -54,7 +55,7 @@ def poll_ftp(cls):
EFTPollerFtpTask._post_process(sftp_client, payment_file_list)

except Exception as e: # NOQA # pylint: disable=broad-except
current_app.logger.error(e)
current_app.logger.error(f"{{error: {str(e)}, stack_trace: {traceback.format_exc()}}}")
return payment_file_list

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion pay-queue/devops/vaults.gcp.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LEGISLATIVE_TIMEZONE="op://relationship/$APP_ENV/pay-api/LEGISLATIVE_TIMEZONE"
ACCOUNT_SECRET_KEY="op://relationship/$APP_ENV/pay-api/ACCOUNT_SECRET_KEY"
DISABLE_EJV_ERROR_EMAIL="True"
DISABLE_CSV_ERROR_EMAIL="True"
IT_OPS_EMAIL='[email protected]'
IT_OPS_EMAIL="op://relationship/$APP_ENV/pay-queue/IT_OPS_EMAIL"
NOTIFY_API_URL="op://API/$APP_ENV/notify-api/NOTIFY_API_URL"
NOTIFY_API_VERSION="op://API/$APP_ENV/notify-api/NOTIFY_API_VERSION"
JWT_OIDC_ISSUER="op://keycloak/$APP_ENV/jwt-base/JWT_OIDC_ISSUER"
Expand Down
5 changes: 3 additions & 2 deletions pay-queue/src/pay_queue/resources/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import dataclasses
import json
import traceback
from http import HTTPStatus

from flask import Blueprint, current_app, request
Expand Down Expand Up @@ -57,7 +58,7 @@ def worker():
current_app.logger.warning("Invalid queue message type: %s", ce.type)

return {}, HTTPStatus.OK
except Exception: # NOQA # pylint: disable=broad-except
except Exception as e: # NOQA # pylint: disable=broad-except
# Catch Exception so that any error is still caught and the message is removed from the queue
current_app.logger.error("Error processing event:", exc_info=True)
current_app.logger.error(f"{{error: {str(e)}, stack_trace: {traceback.format_exc()}}}")
return {}, HTTPStatus.OK

0 comments on commit 958f1c3

Please sign in to comment.