Skip to content

Commit 898791a

Browse files
Don't log exception trace before retrying HA Payment (#751)
without payer info --------- Co-authored-by: Timothée Robert <[email protected]>
1 parent f10a817 commit 898791a

File tree

2 files changed

+60
-7
lines changed

2 files changed

+60
-7
lines changed

app/core/payment/payment_tool.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ async def init_checkout(
204204
# We know that HelloAsso may refuse some payer infos, like using the firstname "test"
205205
# Even when prefilling the payer infos,the user will be able to edit them on the payment page,
206206
# so we can safely retry without the payer infos
207-
hyperion_error_logger.exception(
208-
f"Payment: failed to init a checkout with HA for module {module} and name {checkout_name}. Retrying without payer infos",
207+
payer_user_name = ""
208+
if payer_user:
209+
payer_user_name = f"{payer_user.firstname} {payer_user.name}"
210+
hyperion_error_logger.warning(
211+
f"Payment: failed to init a checkout with HA for module {module} and name {checkout_name}. Retrying without payer {payer_user_name} infos",
209212
)
210213

211214
init_checkout_body.payer = None

app/core/utils/log.py

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ class console_color:
8181
def get_config_dict(self, settings: Settings):
8282
# We can't use a dependency to access settings as this function is not an endpoint. The object must thus be passed as a parameter.
8383

84-
MINIMUM_LOG_LEVEL: str = "DEBUG" if settings.LOG_DEBUG_MESSAGES else "INFO"
84+
# /!\ WARNING /!\
85+
# MINIMUM_LOG_LEVEL should never be set higher than INFO
86+
# as it would prevent important information to be logged, like MyECLPay operations
87+
MINIMUM_LOG_LEVEL: str = (
88+
"DEBUG" if settings.LOG_DEBUG_MESSAGES else "INFO"
89+
) # /!\ read warning before modifying this /!\
8590

8691
return {
8792
"version": 1,
@@ -267,29 +272,29 @@ def get_config_dict(self, settings: Settings):
267272
"matrix_errors",
268273
"console",
269274
],
270-
"level": "DEBUG",
275+
"level": MINIMUM_LOG_LEVEL,
271276
"propagate": False,
272277
},
273278
"hyperion.myeclpay": {
274279
"handlers": [
275280
"myeclpay_s3",
276281
],
277-
"level": "DEBUG",
282+
"level": MINIMUM_LOG_LEVEL,
278283
},
279284
"hyperion.s3.fallback": {
280285
"handlers": [
281286
"file_s3",
282287
"matrix_errors",
283288
"console",
284289
],
285-
"level": "DEBUG",
290+
"level": MINIMUM_LOG_LEVEL,
286291
"propagate": False,
287292
},
288293
"hyperion.s3": {
289294
"handlers": [
290295
"s3",
291296
],
292-
"level": "DEBUG",
297+
"level": MINIMUM_LOG_LEVEL,
293298
},
294299
"hyperion.amap": {
295300
"handlers": [
@@ -327,6 +332,51 @@ def get_config_dict(self, settings: Settings):
327332
"level": MINIMUM_LOG_LEVEL,
328333
"propagate": False,
329334
},
335+
"boto3": {
336+
"handlers": [
337+
"console",
338+
"file_errors",
339+
"matrix_errors",
340+
],
341+
"level": MINIMUM_LOG_LEVEL,
342+
"propagate": False,
343+
},
344+
"botocore": {
345+
"handlers": [
346+
"console",
347+
"file_errors",
348+
"matrix_errors",
349+
],
350+
"level": MINIMUM_LOG_LEVEL,
351+
"propagate": False,
352+
},
353+
"s3transfer": {
354+
"handlers": [
355+
"console",
356+
"file_errors",
357+
"matrix_errors",
358+
],
359+
"level": MINIMUM_LOG_LEVEL,
360+
"propagate": False,
361+
},
362+
"urllib3": {
363+
"handlers": [
364+
"console",
365+
"file_errors",
366+
"matrix_errors",
367+
],
368+
"level": MINIMUM_LOG_LEVEL,
369+
"propagate": False,
370+
},
371+
"python_multipart.multipart": {
372+
"handlers": [
373+
"console",
374+
"file_errors",
375+
"matrix_errors",
376+
],
377+
"level": MINIMUM_LOG_LEVEL,
378+
"propagate": False,
379+
},
330380
},
331381
}
332382

0 commit comments

Comments
 (0)