package components import ( "context" "time" ) // LogEntry represents a log entry for display type LogEntry struct { Timestamp time.Time Level string Message string Source string Details map[string]interface{} } // LogViewerData represents the data for the log viewer component type LogViewerData struct { Logs []LogEntry CurrentFilter string LogFilePath string } // Helper function to get the appropriate CSS class for log levels func getLogLevelClass(level string) string { baseClass := "px-4 py-2 text-sm font-medium whitespace-nowrap " switch level { case "debug": return baseClass + "text-purple-500 dark:text-purple-400" case "info": return baseClass + "text-blue-500 dark:text-blue-400" case "warn": return baseClass + "text-yellow-500 dark:text-yellow-400" case "error": return baseClass + "text-red-500 dark:text-red-400" case "fatal": return baseClass + "text-red-700 dark:text-red-600 font-bold" default: return baseClass + "text-gray-500 dark:text-gray-400" } } // AdminLogs renders the log viewer page templ AdminLogs(ctx context.Context, data LogViewerData) { @LayoutWithContext("Log Viewer", ctx) {
Viewing logs from: { data.LogFilePath }
Real-time log streaming is active, logs are automatically captured and displayed
| Timestamp | Level | Source | Message |
|---|---|---|---|
| Waiting for logs... | |||
| { log.Timestamp.Format("2006-01-02 15:04:05.000") } | { log.Level } | { log.Source } | { log.Message } |