forked from Leak_Technologies/VideoTools
Major refactoring to improve code organization and enhance UI: Architecture: - Split monolithic main.go into modular internal/ package structure - Created internal/logging for centralized logging system - Created internal/modules for module handler functions - Created internal/ui for UI components and layouts - Created internal/utils for shared utility functions UI Enhancements: - Implemented rainbow gradient across 8 module buttons (violet→red) - Increased module button text size to 20 for better readability - Fixed text centering on module tiles - Converted Simple/Advanced mode toggle to tabs to save vertical space - Added vertical scrollbars to prevent UI overflow - Added metadata copy button (📋) to copy all metadata to clipboard Video Processing: - Fixed aspect ratio conversion to default to center-crop behavior - Added 6 aspect handling modes: Auto, Crop, Letterbox, Pillarbox, Blur Fill, Stretch - Fixed blur fill to maintain source resolution with padding (no scaling) - Ensured all FFmpeg filters produce even-numbered dimensions for H.264 Known Issues: - WMV files still produce FFmpeg error 234 during aspect conversions (requires codec-specific handling in future update) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
83 lines
1.8 KiB
Go
83 lines
1.8 KiB
Go
package logging
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
filePath string
|
|
file *os.File
|
|
history []string
|
|
debugEnabled bool
|
|
logger = log.New(os.Stderr, "[videotools] ", log.LstdFlags|log.Lmicroseconds)
|
|
)
|
|
|
|
const historyMax = 500
|
|
|
|
// Category represents a log category
|
|
type Category string
|
|
|
|
const (
|
|
CatUI Category = "[UI]"
|
|
CatCLI Category = "[CLI]"
|
|
CatFFMPEG Category = "[FFMPEG]"
|
|
CatSystem Category = "[SYS]"
|
|
CatModule Category = "[MODULE]"
|
|
)
|
|
|
|
// Init initializes the logging system
|
|
func Init() {
|
|
filePath = os.Getenv("VIDEOTOOLS_LOG_FILE")
|
|
if filePath == "" {
|
|
filePath = "videotools.log"
|
|
}
|
|
f, err := os.OpenFile(filePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "videotools: cannot open log file %s: %v\n", filePath, err)
|
|
return
|
|
}
|
|
file = f
|
|
}
|
|
|
|
// Close closes the log file
|
|
func Close() {
|
|
if file != nil {
|
|
file.Close()
|
|
}
|
|
}
|
|
|
|
// SetDebug enables or disables debug logging
|
|
func SetDebug(on bool) {
|
|
debugEnabled = on
|
|
Debug(CatSystem, "debug logging toggled -> %v (VIDEOTOOLS_DEBUG=%s)", on, os.Getenv("VIDEOTOOLS_DEBUG"))
|
|
}
|
|
|
|
// Debug logs a debug message with a category
|
|
func Debug(cat Category, format string, args ...interface{}) {
|
|
msg := fmt.Sprintf("%s %s", cat, fmt.Sprintf(format, args...))
|
|
timestamp := time.Now().Format(time.RFC3339Nano)
|
|
if file != nil {
|
|
fmt.Fprintf(file, "%s %s\n", timestamp, msg)
|
|
}
|
|
history = append(history, fmt.Sprintf("%s %s", timestamp, msg))
|
|
if len(history) > historyMax {
|
|
history = history[len(history)-historyMax:]
|
|
}
|
|
if debugEnabled {
|
|
logger.Printf("%s %s", timestamp, msg)
|
|
}
|
|
}
|
|
|
|
// FilePath returns the current log file path
|
|
func FilePath() string {
|
|
return filePath
|
|
}
|
|
|
|
// History returns the log history
|
|
func History() []string {
|
|
return history
|
|
}
|