feat: add server-sent events for logging and activity tracking
- Implemented a custom tracing layer (`AppLogLayer`) to capture log events and broadcast them to SSE clients. - Created admin routes for streaming server logs and listing recent activity logs. - Added an activity log repository interface and SQLite implementation for persisting activity events. - Integrated activity logging into user authentication and channel CRUD operations. - Developed frontend components for displaying server logs and activity logs in the admin panel. - Enhanced the video player with a stats overlay for monitoring streaming metrics.
This commit is contained in:
@@ -12,6 +12,16 @@ use crate::entities::{Channel, GeneratedSchedule, PlaybackRecord, User};
|
||||
use crate::errors::DomainResult;
|
||||
use crate::value_objects::{ChannelId, UserId};
|
||||
|
||||
/// An in-app activity event stored in the database for the admin log view.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ActivityEvent {
|
||||
pub id: Uuid,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
pub event_type: String,
|
||||
pub detail: String,
|
||||
pub channel_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
/// Repository port for User persistence
|
||||
#[async_trait]
|
||||
pub trait UserRepository: Send + Sync {
|
||||
@@ -71,3 +81,15 @@ pub trait ScheduleRepository: Send + Sync {
|
||||
|
||||
async fn save_playback_record(&self, record: &PlaybackRecord) -> DomainResult<()>;
|
||||
}
|
||||
|
||||
/// Repository port for activity log persistence.
|
||||
#[async_trait]
|
||||
pub trait ActivityLogRepository: Send + Sync {
|
||||
async fn log(
|
||||
&self,
|
||||
event_type: &str,
|
||||
detail: &str,
|
||||
channel_id: Option<Uuid>,
|
||||
) -> DomainResult<()>;
|
||||
async fn recent(&self, limit: u32) -> DomainResult<Vec<ActivityEvent>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user