Skip to content

Commit

Permalink
🐛 fix logger format error
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Aug 18, 2024
1 parent 67a371f commit 8019b5a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/plugins/github/libs/renderer/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2023-10-18 16:20:28
@LastEditors : yanyongyu
@LastEditTime : 2024-08-18 17:07:10
@LastEditTime : 2024-08-18 17:29:14
@Description : None
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -938,7 +938,8 @@ async def from_issue(
event_data = event.model_dump(exclude_unset=True)
logger.debug(f"Unhandled event: {event_data}")
logger.error(
f"Unhandled event type: {event.__class__.__name__}"
"Unhandled event type: {event_type}",
event_type=f"{event.__class__.__name__}"
+ (
f" {event_name}"
if (event_name := getattr(event, "event", None))
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/github/libs/renderer/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2022-09-14 16:07:50
@LastEditors : yanyongyu
@LastEditTime : 2024-05-15 17:08:11
@LastEditTime : 2024-08-18 17:29:43
@Description : Jinja filters for renderer
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -92,7 +92,8 @@ def debug_event(event: TimelineEvent) -> str:
event_data = asdict(event)
logger.debug(f"Unhandled event: {event_data}")
logger.error(
f"Unhandled event type: {event.__class__.__name__}"
"Unhandled event type: {event_type}",
event_type=f"{event.__class__.__name__}"
+ (f" {event_name}" if (event_name := getattr(event, "event", None)) else ""),
event=event_data,
)
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/github/webhooks/issue_commented.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2023-04-26 18:39:12
@LastEditors : yanyongyu
@LastEditTime : 2024-03-05 14:40:23
@LastEditTime : 2024-08-18 17:26:21
@Description : None
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -100,8 +100,9 @@ async def handle_issue_opened_event(
)
except Exception as e:
logger.opt(exception=e).warning(
f"Send message to subscriber failed: {e}",
"Send message to subscriber failed: {e}",
target_info=target.to_subscriber_info(),
e=e,
)

await asyncio.sleep(SEND_INTERVAL)
5 changes: 3 additions & 2 deletions src/plugins/github/webhooks/issue_opened.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2023-04-04 20:02:19
@LastEditors : yanyongyu
@LastEditTime : 2024-03-05 14:41:51
@LastEditTime : 2024-08-18 17:26:48
@Description : Webhook issue opened broadcast
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -98,8 +98,9 @@ async def handle_issue_opened_event(
)
except Exception as e:
logger.opt(exception=e).warning(
f"Send message to subscriber failed: {e}",
"Send message to subscriber failed: {e}",
target_info=target.to_subscriber_info(),
e=e,
)

await asyncio.sleep(SEND_INTERVAL)
5 changes: 3 additions & 2 deletions src/plugins/github/webhooks/release_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2023-04-04 20:02:19
@LastEditors : yanyongyu
@LastEditTime : 2024-08-18 16:41:02
@LastEditTime : 2024-08-18 17:26:59
@Description : Webhook release publish broadcast
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -59,8 +59,9 @@ async def handle_release_published_event(
)
except Exception as e:
logger.opt(exception=e).warning(
f"Send message to subscriber failed: {e}",
"Send message to subscriber failed: {e}",
target_info=target.to_subscriber_info(),
e=e,
)

await asyncio.sleep(SEND_INTERVAL)
5 changes: 3 additions & 2 deletions src/plugins/github/webhooks/star.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2022-12-18 13:44:11
@LastEditors : yanyongyu
@LastEditTime : 2023-10-08 18:02:15
@LastEditTime : 2024-08-18 17:27:13
@Description : Webhook star event broadcast
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -56,8 +56,9 @@ async def handle_star_event(event: StarCreated | StarDeleted, subscribers: SUBSC
await send_subscriber_text(target.to_subscriber_info(), message, tag)
except Exception as e:
logger.opt(exception=e).warning(
f"Send message to subscriber failed: {e}",
"Send message to subscriber failed: {e}",
target_info=target.to_subscriber_info(),
e=e,
)

await asyncio.sleep(SEND_INTERVAL)
5 changes: 3 additions & 2 deletions src/plugins/github/webhooks/unknown.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@Author : yanyongyu
@Date : 2022-11-07 05:14:32
@LastEditors : yanyongyu
@LastEditTime : 2023-10-08 17:43:38
@LastEditTime : 2024-08-18 17:27:21
@Description : Webhook unknown event broadcast
@GitHub : https://github.com/yanyongyu
"""
Expand Down Expand Up @@ -60,8 +60,9 @@ async def handle_unknown_event(
await send_subscriber_text(target.to_subscriber_info(), message, tag)
except Exception as e:
logger.opt(exception=e).warning(
f"Send message to subscriber failed: {e}",
"Send message to subscriber failed: {e}",
target_info=target.to_subscriber_info(),
e=e,
)

await asyncio.sleep(SEND_INTERVAL)

0 comments on commit 8019b5a

Please sign in to comment.