diff --git a/components/admin_logs.templ b/components/admin_logs.templ new file mode 100644 index 0000000..b37321a --- /dev/null +++ b/components/admin_logs.templ @@ -0,0 +1,536 @@ +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 +} + +// AdminLogs renders the log viewer page +templ AdminLogs(ctx context.Context, data LogViewerData) { + @LayoutWithContext("Log Viewer", ctx) { +
+ +
+

+ Log Viewer +

+
+ + + + +
+
+ + +
+
+

Viewing logs from: { data.LogFilePath }

+

Real-time log streaming is active, logs are automatically captured and displayed

+
+
+ + +
+
+

Filter Logs

+
+
+
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+
+
+ + +
+
+

Live Logs

+
+ + + Connected + +
+
+ +
+ + + + + + + + + + + + if len(data.Logs) == 0 { + + + + } else { + for _, log := range data.Logs { + + + + + + + } + } + +
TimestampLevelSourceMessage
Waiting for logs...
{ log.Timestamp.Format("2006-01-02 15:04:05.000") }{ log.Level }{ log.Source }{ log.Message }
+
+
+
+ + + } +} + +// 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" + } +} \ No newline at end of file diff --git a/components/layout.templ b/components/layout.templ index b7c9006..c318405 100644 --- a/components/layout.templ +++ b/components/layout.templ @@ -193,6 +193,10 @@ templ LayoutWithContext(title string, ctx context.Context) { Audit Logs + + + Log Viewer + Database Tools @@ -293,19 +297,23 @@ templ LayoutWithContext(title string, ctx context.Context) { Audit Logs + + + Log Viewer + Database Tools // Settings Dropdown - -