feat(logging): add LOG_ADMIN_HIDE setting and update logging functionality

Introduce a new configuration option `LOG_ADMIN_HIDE` to control the visibility of admin-generated events in the logs. Update the logging retrieval functions to respect this setting, ensuring that admin actions can be hidden from the "All message logs" UI and CSV exports. Additionally, enhance the README with detailed logging configuration options for better clarity.
This commit is contained in:
kavore
2026-02-12 10:48:48 +03:00
parent 826b036724
commit 0bd3d70e12
6 changed files with 69 additions and 20 deletions
+12 -5
View File
@@ -22,16 +22,23 @@ async def create_message_log(session: AsyncSession,
return None
async def get_all_message_logs(session: AsyncSession, limit: int,
offset: int) -> List[MessageLog]:
stmt = select(MessageLog).order_by(
MessageLog.timestamp.desc()).limit(limit).offset(offset)
async def get_all_message_logs(session: AsyncSession,
limit: int,
offset: int,
hide_admin_events: bool = False) -> List[MessageLog]:
stmt = select(MessageLog)
if hide_admin_events:
stmt = stmt.where(MessageLog.is_admin_event.is_(False))
stmt = stmt.order_by(MessageLog.timestamp.desc()).limit(limit).offset(offset)
result = await session.execute(stmt)
return result.scalars().all()
async def count_all_message_logs(session: AsyncSession) -> int:
async def count_all_message_logs(session: AsyncSession,
hide_admin_events: bool = False) -> int:
stmt = select(func.count()).select_from(MessageLog)
if hide_admin_events:
stmt = stmt.where(MessageLog.is_admin_event.is_(False))
result = await session.execute(stmt)
return result.scalar_one()