Allow plugins to set a log formatter when TTY isn't allocated (#385)

This commit is contained in:
Matej Trop 2024-05-17 19:42:28 +01:00 committed by GitHub
parent 70fb830dca
commit 9cd6050812
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,10 +49,12 @@ func ConfigStdioLogrus(p SshPiperPlugin, formatter logrus.Formatter, logger *log
lv, _ := logrus.ParseLevel(level)
logger.SetLevel(lv)
if formatter != nil {
logger.SetFormatter(formatter)
}
if tty {
if formatter != nil {
logger.SetFormatter(formatter)
} else {
if formatter == nil {
logger.SetFormatter(&logrus.TextFormatter{ForceColors: true})
}
}