mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
e0ecc9e835
I'll be honest, for all I know logging should be global in general: it is a pain to pass a logger to any struct that needs it. But smart people on the internet tell me otherwise, and I do like the idea of not having any global variables lying around. Nonetheless, I often need to log things when locally debugging and that's a different kind of logging than the kind you would include in the actual released binary. For example if I want to log something from gocui, I would rather not have gocui depend on lazygit's logging setup.
32 lines
544 B
Go
32 lines
544 B
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package tail
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/aybabtme/humanlog"
|
|
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
|
)
|
|
|
|
func tailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
|
|
cmd := secureexec.Command("tail", "-f", logFilePath)
|
|
|
|
stdout, _ := cmd.StdoutPipe()
|
|
if err := cmd.Start(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := humanlog.Scanner(stdout, os.Stdout, opts); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := cmd.Wait(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
os.Exit(0)
|
|
}
|