fix: resolve logging syntax errors
- Fix missing closing brace in Error function - Remove stray empty line causing syntax error - Ensure all functions are properly closed - Maintain structured logging functionality
This commit is contained in:
parent
3c6e57d0b4
commit
d6e1b14e7d
|
|
@ -152,6 +152,23 @@ func Crash(cat Category, format string, args ...interface{}) {
|
||||||
crashFile.Sync()
|
crashFile.Sync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func Crash(cat Category, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf("%s CRASH: %s", cat, fmt.Sprintf(format, args...))
|
||||||
|
timestamp := time.Now().Format(time.RFC3339Nano)
|
||||||
|
|
||||||
|
// Log to main log file
|
||||||
|
if file != nil {
|
||||||
|
fmt.Fprintf(file, "%s %s\n", timestamp, msg)
|
||||||
|
}
|
||||||
|
logger.Printf("%s %s", timestamp, msg)
|
||||||
|
|
||||||
|
// Also log to dedicated crash log
|
||||||
|
if crashFile, err := os.OpenFile(GetCrashLogPath(), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644); err == nil {
|
||||||
|
fmt.Fprintf(crashFile, "%s %s\n", timestamp, msg)
|
||||||
|
fmt.Fprintf(crashFile, "Stack trace:\n%s\n", timestamp, getStackTrace())
|
||||||
|
crashFile.Sync()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fatal logs a fatal error and exits (always logged, even when debug is off)
|
// Fatal logs a fatal error and exits (always logged, even when debug is off)
|
||||||
func Fatal(cat Category, format string, args ...interface{}) {
|
func Fatal(cat Category, format string, args ...interface{}) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user