debug: add WriteDebugLog inside iframe to confirm calendar-data delivery + log.Printf to WriteDebugLog

This commit is contained in:
mirivlad 2026-06-08 12:34:14 +08:00
parent c03e2e2961
commit f4a25128ae
2 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
@ -13,6 +14,7 @@ func (a *App) WriteDebugLog(msg string) {
if !a.IsReady() { if !a.IsReady() {
return return
} }
log.Printf("[js] %s", msg)
logPath := filepath.Join(a.vault, ".verstak", "debug.log") logPath := filepath.Join(a.vault, ".verstak", "debug.log")
line := fmt.Sprintf("[%s] %s\n", time.Now().Format("2006-01-02T15:04:05"), msg) line := fmt.Sprintf("[%s] %s\n", time.Now().Format("2006-01-02T15:04:05"), msg)
f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)

View File

@ -431,6 +431,7 @@ body {
switch (msg.type) { switch (msg.type) {
case 'calendar-data': case 'calendar-data':
try { window.parent.go.main.App.WriteDebugLog('[iframe] received calendar-data, events=' + (msg.events ? msg.events.length : 0) + ', categories=' + (msg.categories ? msg.categories.length : 0)); } catch(e) { try { console.log('iframe debug error: ' + e); } catch(e2) {} }
if (msg.events) state.events = msg.events; if (msg.events) state.events = msg.events;
if (msg.categories) state.categories = msg.categories; if (msg.categories) state.categories = msg.categories;
state.eventsLoaded = true; state.eventsLoaded = true;