Something went wrong. Try again.
search and/or read your saved and liked bluesky posts
wails go svelte sqlite desktop bluesky
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133package main
import ( "fmt" "log" "os")
// AppLogger provides application logging that writes to both file and Wails eventstype AppLogger struct { stdLogger *log.Logger service *LogService}
var appLogger *AppLogger
// InitLogger initializes the application logger with the log servicefunc InitLogger(service *LogService) { multiWriter := service.GetMultiWriter() appLogger = &AppLogger{ stdLogger: log.New(multiWriter, "", log.LstdFlags|log.Lshortfile), service: service, }
log.SetOutput(multiWriter)}
// GetLogger returns the global app loggerfunc GetLogger() *AppLogger { if appLogger == nil { return &AppLogger{ stdLogger: log.New(os.Stdout, "", log.LstdFlags), } } return appLogger}
// Debug logs a debug messagefunc (l *AppLogger) Debug(msg string) { l.stdLogger.Printf("[DEBUG] %s", msg)}
// Debugf logs a formatted debug messagefunc (l *AppLogger) Debugf(format string, args ...interface{}) { l.stdLogger.Printf("[DEBUG] "+format, args...)}
// Info logs an info messagefunc (l *AppLogger) Info(msg string) { l.stdLogger.Printf("[INFO] %s", msg)}
// Infof logs a formatted info messagefunc (l *AppLogger) Infof(format string, args ...interface{}) { l.stdLogger.Printf("[INFO] "+format, args...)}
// Warn logs a warning messagefunc (l *AppLogger) Warn(msg string) { l.stdLogger.Printf("[WARN] %s", msg)}
// Warnf logs a formatted warning messagefunc (l *AppLogger) Warnf(format string, args ...interface{}) { l.stdLogger.Printf("[WARN] "+format, args...)}
// Error logs an error messagefunc (l *AppLogger) Error(msg string) { l.stdLogger.Printf("[ERROR] %s", msg)}
// Errorf logs a formatted error messagefunc (l *AppLogger) Errorf(format string, args ...interface{}) { l.stdLogger.Printf("[ERROR] "+format, args...)}
// Fatal logs a fatal message and exitsfunc (l *AppLogger) Fatal(msg string) { l.stdLogger.Fatalf("[FATAL] %s", msg)}
// Fatalf logs a formatted fatal message and exitsfunc (l *AppLogger) Fatalf(format string, args ...interface{}) { l.stdLogger.Fatalf("[FATAL] "+format, args...)}
// Convenience functions that use the global loggerfunc LogDebug(msg string) { GetLogger().Debug(msg)}
func LogDebugf(format string, args ...interface{}) { GetLogger().Debugf(format, args...)}
func LogInfo(msg string) { GetLogger().Info(msg)}
func LogInfof(format string, args ...interface{}) { GetLogger().Infof(format, args...)}
func LogWarn(msg string) { GetLogger().Warn(msg)}
func LogWarnf(format string, args ...interface{}) { GetLogger().Warnf(format, args...)}
func LogError(msg string) { GetLogger().Error(msg)}
func LogErrorf(format string, args ...interface{}) { GetLogger().Errorf(format, args...)}
func LogFatal(msg string) { GetLogger().Fatal(msg)}
func LogFatalf(format string, args ...interface{}) { GetLogger().Fatalf(format, args...)}
// String returns a string representation of the loggerfunc (l *AppLogger) String() string { return fmt.Sprintf("AppLogger{initialized: %v}", l.service != nil)}