-
Notifications
You must be signed in to change notification settings - Fork 0
Implementação de logging usando Loguru #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3d627df
6981821
3c0c977
d2d5303
5e3dee8
ed771e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| DATABASE_URL="sqlite:///./db.sqlite3" # Conexão para o banco de dados | ||
| JWT_SECRET_KEY="SUA_SECRET_KEY" # Recomendo gerar uma chave usando: python -c "import secrets; print(secrets.token_hex(32))" | ||
| JWT_EXPIRATION_TIME=30 # Tempo de expiração do token em minutos | ||
| JWT_EXPIRATION_TIME=30 # Tempo de expiração do token em minutos | ||
| WEBHOOK_LOG_INFO="" # Preencha com o seu link de webhook | ||
| WEBHOOK_LOG_ERROR="" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| import asyncio | ||||||
| from datetime import datetime | ||||||
| import threading | ||||||
| import httpx | ||||||
| from loguru import logger | ||||||
| from src.settings import WEBHOOK_INFO, WEBHOOK_ERROR | ||||||
|
|
||||||
| def send_webhook(message: str, webhook_url: str): | ||||||
| def runner(): | ||||||
| async def task(): | ||||||
| try: | ||||||
| async with httpx.AsyncClient(timeout=5) as client: | ||||||
| await client.post(webhook_url, json={"content": message}) | ||||||
| except Exception as e: | ||||||
| logger.error(f"[Log Error]: {e}") | ||||||
mtzdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| logger.error(f"[Log Error]: {e}") | |
| print(f"[Log Error]: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The webhook URLs are imported without validation. If these environment variables are None or empty, the webhook calls will fail. Add validation to ensure webhooks are properly configured before attempting to send messages.