fix: restore Info logging functionality and enhance console output for error messages

This commit is contained in:
jahruz67
2026-05-19 18:03:48 -07:00
parent 00f4912cc3
commit fb555ea533
+9 -3
View File
@@ -67,9 +67,8 @@ func Close() {
} }
// Info logs an informational message with timestamp. // Info logs an informational message with timestamp.
// Modified to do nothing so only errors are logged.
func Info(format string, args ...interface{}) { func Info(format string, args ...interface{}) {
// Do nothing log("INFO", format, args...)
} }
// Error logs an error message with timestamp. // Error logs an error message with timestamp.
@@ -77,7 +76,7 @@ func Error(format string, args ...interface{}) {
log("ERROR", format, args...) log("ERROR", format, args...)
} }
// log writes a formatted log message to the log file. // log writes a formatted log message to the log file and console.
func log(level, format string, args ...interface{}) { func log(level, format string, args ...interface{}) {
logMutex.Lock() logMutex.Lock()
defer logMutex.Unlock() defer logMutex.Unlock()
@@ -95,6 +94,13 @@ func log(level, format string, args ...interface{}) {
message := fmt.Sprintf(format, args...) message := fmt.Sprintf(format, args...)
logLine := fmt.Sprintf("[%s] %s: %s\n", timestamp, level, message) logLine := fmt.Sprintf("[%s] %s: %s\n", timestamp, level, message)
// Print to console for real-time terminal output
if level == "ERROR" {
fmt.Fprint(os.Stderr, logLine)
} else {
fmt.Fprint(os.Stdout, logLine)
}
if logFile != nil { if logFile != nil {
logFile.WriteString(logLine) logFile.WriteString(logLine)
logFile.Sync() logFile.Sync()