summaryrefslogtreecommitdiffstats
path: root/pkg/app
diff options
context:
space:
mode:
authorDavyd McColl <davydm@gmail.com>2021-06-15 09:31:52 +0200
committerJesse Duffield <jessedduffield@gmail.com>2021-07-01 17:13:14 +1000
commit53ea7df655a8d4893fa623a65d16c7bffded779b (patch)
tree33826670d4a0a0ab7245fb2d99c70c8dd56d969e /pkg/app
parent533817bda3d01f72acac83d6f333bd573d35b913 (diff)
:truck: move only the platform-specific part of log tailing into platform-specific files
Diffstat (limited to 'pkg/app')
-rw-r--r--pkg/app/app.go23
-rw-r--r--pkg/app/logging.go22
-rw-r--r--pkg/app/logging_windows.go26
3 files changed, 25 insertions, 46 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index fd4df9d75..52a168796 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -4,6 +4,7 @@ import (
"bufio"
"errors"
"fmt"
+ "github.com/aybabtme/humanlog"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config"
@@ -306,3 +307,25 @@ func (app *App) KnownError(err error) (string, bool) {
}
return "", false
}
+
+func TailLogs() {
+ logFilePath, err := config.LogPath()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Printf("Tailing log file %s\n\n", logFilePath)
+
+ opts := humanlog.DefaultOptions
+ opts.Truncates = false
+
+ _, err = os.Stat(logFilePath)
+ if err != nil {
+ if os.IsNotExist(err) {
+ log.Fatal("Log file does not exist. Run `lazygit --debug` first to create the log file")
+ }
+ log.Fatal(err)
+ }
+
+ TailLogsForPlatform(logFilePath, opts)
+}
diff --git a/pkg/app/logging.go b/pkg/app/logging.go
index 93e5287e8..6a3c1e7c0 100644
--- a/pkg/app/logging.go
+++ b/pkg/app/logging.go
@@ -3,33 +3,13 @@
package app
import (
- "fmt"
"github.com/aybabtme/humanlog"
- "github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/secureexec"
"log"
"os"
)
-func TailLogs() {
- logFilePath, err := config.LogPath()
- if err != nil {
- log.Fatal(err)
- }
-
- fmt.Printf("Tailing log file %s\n\n", logFilePath)
-
- opts := humanlog.DefaultOptions
- opts.Truncates = false
-
- _, err = os.Stat(logFilePath)
- if err != nil {
- if os.IsNotExist(err) {
- log.Fatal("Log file does not exist. Run `lazygit --debug` first to create the log file")
- }
- log.Fatal(err)
- }
-
+func TailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
cmd := secureexec.Command("tail", "-f", logFilePath)
stdout, _ := cmd.StdoutPipe()
diff --git a/pkg/app/logging_windows.go b/pkg/app/logging_windows.go
index 8c3e937a1..affd5a018 100644
--- a/pkg/app/logging_windows.go
+++ b/pkg/app/logging_windows.go
@@ -4,38 +4,14 @@ package app
import (
"bufio"
- "fmt"
"github.com/aybabtme/humanlog"
- "github.com/jesseduffield/lazygit/pkg/config"
"log"
"os"
"strings"
"time"
)
-func TailLogs() {
- logFilePath, err := config.LogPath()
- if err != nil {
- log.Fatal(err)
- }
-
- fmt.Printf("Tailing log file %s\n\n", logFilePath)
-
- opts := humanlog.DefaultOptions
- opts.Truncates = false
-
- _, err = os.Stat(logFilePath)
- if err != nil {
- if os.IsNotExist(err) {
- log.Fatal("Log file does not exist. Run `lazygit --debug` first to create the log file")
- }
- log.Fatal(err)
- }
-
- TailLogsNative(logFilePath, opts)
-}
-
-func TailLogsNative(logFilePath string, opts *humanlog.HandlerOptions) {
+func TailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
var lastModified int64 = 0
var lastOffset int64 = 0
for {