summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-09-26 10:23:10 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-09-26 11:00:50 +1000
commit077f11361805417c15234c62a9f9aa022f913d43 (patch)
tree2cf25beba4f96b55392f09d733a14c25c149de07 /pkg/gui
parent0c6cbe7746660155df0645f01d37150099d21f49 (diff)
add in-built logging support for a better dev experience
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/app_status_manager.go1
-rw-r--r--pkg/gui/cherry_picking.go2
-rw-r--r--pkg/gui/context.go1
-rw-r--r--pkg/gui/file_watching.go7
-rw-r--r--pkg/gui/gui.go2
-rw-r--r--pkg/gui/layout.go2
-rw-r--r--pkg/gui/list_context.go1
-rw-r--r--pkg/gui/merge_panel.go2
-rw-r--r--pkg/gui/view_helpers.go47
9 files changed, 52 insertions, 13 deletions
diff --git a/pkg/gui/app_status_manager.go b/pkg/gui/app_status_manager.go
index 9d8ac3725..39f2940e2 100644
--- a/pkg/gui/app_status_manager.go
+++ b/pkg/gui/app_status_manager.go
@@ -62,7 +62,6 @@ func (gui *Gui) WithWaitingStatus(name string, f func() error) error {
defer ticker.Stop()
for range ticker.C {
appStatus := gui.statusManager.getStatusString()
- gui.Log.Warn(appStatus)
if appStatus == "" {
return
}
diff --git a/pkg/gui/cherry_picking.go b/pkg/gui/cherry_picking.go
index 04e7517b7..4b853d637 100644
--- a/pkg/gui/cherry_picking.go
+++ b/pkg/gui/cherry_picking.go
@@ -182,7 +182,7 @@ func (gui *Gui) rerenderContextViewIfPresent(contextKey string) error {
view, err := gui.g.View(viewName)
if err != nil {
- gui.Log.Warn(err)
+ gui.Log.Error(err)
return nil
}
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 937106953..a7b887199 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -610,7 +610,6 @@ func (gui *Gui) onViewFocusLost(v *gocui.View, newView *gocui.View) error {
}
}
- gui.Log.Info(v.Name() + " focus lost")
return nil
}
diff --git a/pkg/gui/file_watching.go b/pkg/gui/file_watching.go
index 7e5e20a76..81a0c97fc 100644
--- a/pkg/gui/file_watching.go
+++ b/pkg/gui/file_watching.go
@@ -59,15 +59,14 @@ func (w *fileWatcher) popOldestFilename() {
w.WatchedFilenames = w.WatchedFilenames[1:]
if err := w.Watcher.Remove(oldestFilename); err != nil {
// swallowing errors here because it doesn't really matter if we can't unwatch a file
- w.Log.Warn(err)
+ w.Log.Error(err)
}
}
func (w *fileWatcher) watchFilename(filename string) {
- w.Log.Warn(filename)
if err := w.Watcher.Add(filename); err != nil {
// swallowing errors here because it doesn't really matter if we can't watch a file
- w.Log.Warn(err)
+ w.Log.Error(err)
}
// assume we're watching it now to be safe
@@ -138,7 +137,7 @@ func (gui *Gui) watchFilesForChanges() {
// watch for errors
case err := <-gui.fileWatcher.Watcher.Errors:
if err != nil {
- gui.Log.Warn(err)
+ gui.Log.Error(err)
}
}
}
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 858bbef5f..db6624ec0 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -450,7 +450,7 @@ func (gui *Gui) Run() error {
g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout()))
- gui.Log.Warn("starting main loop")
+ gui.Log.Info("starting main loop")
err = g.MainLoop()
return err
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index 583e50071..a52f95ba5 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -327,7 +327,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
// here is a good place log some stuff
- // if you download humanlog and do tail -f development.log | humanlog
+ // if you run `lazygit --logs`
// this will let you see these branches as prettified json
// gui.Log.Info(utils.AsJson(gui.State.Branches[0:4]))
return gui.resizeCurrentPopupPanel()
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go
index e437337d1..1ba7da80a 100644
--- a/pkg/gui/list_context.go
+++ b/pkg/gui/list_context.go
@@ -412,7 +412,6 @@ func (gui *Gui) subCommitsListContext() *ListContext {
ResetMainViewOriginOnFocus: true,
Kind: SIDE_CONTEXT,
GetDisplayStrings: func() [][]string {
- gui.Log.Warn("getting display strings for sub commits")
return presentation.GetCommitListDisplayStrings(gui.State.SubCommits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap(), gui.State.Modes.Diffing.Ref)
},
SelectedItem: func() (ListItem, bool) {
diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go
index c19987585..f09b77d2d 100644
--- a/pkg/gui/merge_panel.go
+++ b/pkg/gui/merge_panel.go
@@ -30,7 +30,6 @@ func (gui *Gui) findConflicts(content string) []commands.Conflict {
var newConflict commands.Conflict
for i, line := range utils.SplitLines(content) {
trimmedLine := strings.TrimPrefix(line, "++")
- gui.Log.Info(trimmedLine)
if trimmedLine == "<<<<<<< HEAD" || trimmedLine == "<<<<<<< MERGE_HEAD" || trimmedLine == "<<<<<<< Updated upstream" || trimmedLine == "<<<<<<< ours" {
newConflict = commands.Conflict{Start: i}
} else if trimmedLine == "=======" {
@@ -140,7 +139,6 @@ func (gui *Gui) resolveConflict(conflict commands.Conflict, pick string) error {
output += line
}
}
- gui.Log.Info(output)
return ioutil.WriteFile(gitFile.Name, []byte(output), 0644)
}
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 796b7dca6..d7eab73ba 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -27,6 +27,39 @@ const (
STATUS
)
+func getScopeNames(scopes []int) []string {
+ scopeNameMap := map[int]string{
+ COMMITS: "commits",
+ BRANCHES: "branches",
+ FILES: "files",
+ STASH: "stash",
+ REFLOG: "reflog",
+ TAGS: "tags",
+ REMOTES: "remotes",
+ STATUS: "status",
+ }
+
+ scopeNames := make([]string, len(scopes))
+ for i, scope := range scopes {
+ scopeNames[i] = scopeNameMap[scope]
+ }
+
+ return scopeNames
+}
+
+func getModeName(mode int) string {
+ switch mode {
+ case SYNC:
+ return "sync"
+ case ASYNC:
+ return "async"
+ case BLOCK_UI:
+ return "block-ui"
+ default:
+ return "unknown mode"
+ }
+}
+
const (
SYNC = iota // wait until everything is done before returning
ASYNC // return immediately, allowing each independent thing to update itself
@@ -48,6 +81,19 @@ func intArrToMap(arr []int) map[int]bool {
}
func (gui *Gui) refreshSidePanels(options refreshOptions) error {
+ if options.scope == nil {
+ gui.Log.Infof(
+ "refreshing all scopes in %s mode",
+ getModeName(options.mode),
+ )
+ } else {
+ gui.Log.Infof(
+ "refreshing the following scopes in %s mode: %s",
+ getModeName(options.mode),
+ strings.Join(getScopeNames(options.scope), ","),
+ )
+ }
+
wg := sync.WaitGroup{}
f := func() {
@@ -283,7 +329,6 @@ func (gui *Gui) resizePopupPanel(v *gocui.View) error {
if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
return nil
}
- gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
_, err := gui.g.SetView(v.Name(), x0, y0, x1, y1, 0)
return err
}