jim800121chen c54f16fca0 Initial commit: visionA monorepo with local-tool subproject
local-tool/: visionA-local desktop app
- M1: Wails shell + Go server + Next.js UI + Mock mode (macOS dmg ready)
- M2: i18n (zh-TW/en) + Settings 4-tab refactor
- M3: Embedded Python 3.12 runtime (python-build-standalone) + KneronPLUS wheels
- M4: Windows Inno Setup script (build on Windows runner)
- M5: Linux AppImage script + udev rule (build on Linux runner)
- M6: ffmpeg (GPL, pending legal review) + yt-dlp bundled
- Lifecycle: watchServer health check, fatal native dialog,
            Wails IPC raise endpoint, stale process cleanup

.autoflow/: full PRD / Design Spec / Architecture / Testing docs
            (4 rounds tri-party discussion + cross review)
.github/workflows/: macOS / Windows / Linux build CI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:10:38 +08:00

67 lines
1.6 KiB
Go

package logger
import (
"fmt"
"log"
"os"
)
type Logger struct {
info *log.Logger
warn *log.Logger
err *log.Logger
debug *log.Logger
level string
broadcaster *Broadcaster
}
func New(level string) *Logger {
return &Logger{
info: log.New(os.Stdout, "[INFO] ", log.Ldate|log.Ltime|log.Lshortfile),
warn: log.New(os.Stdout, "[WARN] ", log.Ldate|log.Ltime|log.Lshortfile),
err: log.New(os.Stderr, "[ERROR] ", log.Ldate|log.Ltime|log.Lshortfile),
debug: log.New(os.Stdout, "[DEBUG] ", log.Ldate|log.Ltime|log.Lshortfile),
level: level,
}
}
// SetBroadcaster attaches a log broadcaster for real-time log streaming.
func (l *Logger) SetBroadcaster(b *Broadcaster) {
l.broadcaster = b
}
// GetBroadcaster returns the attached broadcaster (may be nil).
func (l *Logger) GetBroadcaster() *Broadcaster {
return l.broadcaster
}
func (l *Logger) Info(msg string, args ...interface{}) {
l.info.Printf(msg, args...)
if l.broadcaster != nil {
l.broadcaster.Push("INFO", fmt.Sprintf(msg, args...))
}
}
func (l *Logger) Warn(msg string, args ...interface{}) {
l.warn.Printf(msg, args...)
if l.broadcaster != nil {
l.broadcaster.Push("WARN", fmt.Sprintf(msg, args...))
}
}
func (l *Logger) Error(msg string, args ...interface{}) {
l.err.Printf(msg, args...)
if l.broadcaster != nil {
l.broadcaster.Push("ERROR", fmt.Sprintf(msg, args...))
}
}
func (l *Logger) Debug(msg string, args ...interface{}) {
if l.level == "debug" {
l.debug.Printf(msg, args...)
if l.broadcaster != nil {
l.broadcaster.Push("DEBUG", fmt.Sprintf(msg, args...))
}
}
}