Separate the runs in the debug log with a blank line

This makes it much easier to find where a new run starts; previously you
had to search for `git --version` for that.
This commit is contained in:
Stefan Haller 2026-08-15 08:03:32 +02:00
parent d298a7ce4b
commit 0140e19eb2

View file

@ -4,6 +4,7 @@ import (
"io"
"log"
"os"
"sync"
"time"
"github.com/sirupsen/logrus"
@ -35,6 +36,11 @@ func NewProductionLogger() *logrus.Entry {
return formatted(logger)
}
// Separates one run's log entries from the previous run's. Only the first
// logger of a run writes it: with LAZYGIT_LOG_PATH set there are two of them
// for the same file, the global one and the app's.
var runSeparator sync.Once
func NewDevelopmentLogger(logPath string) *logrus.Entry {
logger := logrus.New()
logger.SetLevel(getLogLevel())
@ -43,6 +49,9 @@ func NewDevelopmentLogger(logPath string) *logrus.Entry {
if err != nil {
log.Fatalf("Unable to log to log file: %v", err)
}
runSeparator.Do(func() {
_, _ = file.WriteString("\n")
})
logger.SetOutput(file)
return formatted(logger)
}