mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
switch to using the log package rather than directly writing to file
This commit is contained in:
parent
9537645d0c
commit
44eaccfd14
@ -131,7 +131,7 @@ func getSelectedCommit(g *gocui.Gui) (Commit, error) {
|
|||||||
}
|
}
|
||||||
lineNumber := getItemPosition(v)
|
lineNumber := getItemPosition(v)
|
||||||
if lineNumber > len(state.Commits)-1 {
|
if lineNumber > len(state.Commits)-1 {
|
||||||
colorLog(color.FgRed, "potential error in getSelected Commit (mismatched ui and state)", state.Commits, lineNumber)
|
devLog("potential error in getSelected Commit (mismatched ui and state)", state.Commits, lineNumber)
|
||||||
return state.Commits[len(state.Commits)-1], nil
|
return state.Commits[len(state.Commits)-1], nil
|
||||||
}
|
}
|
||||||
return state.Commits[lineNumber], nil
|
return state.Commits[lineNumber], nil
|
||||||
|
15
main.go
15
main.go
@ -11,7 +11,6 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
git "gopkg.in/src-d/go-git.v4"
|
git "gopkg.in/src-d/go-git.v4"
|
||||||
)
|
)
|
||||||
@ -45,18 +44,14 @@ func projectPath(path string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func devLog(objects ...interface{}) {
|
func devLog(objects ...interface{}) {
|
||||||
localLog(color.FgWhite, "development.log", objects...)
|
localLog("development.log", objects...)
|
||||||
}
|
|
||||||
|
|
||||||
func colorLog(colour color.Attribute, objects ...interface{}) {
|
|
||||||
localLog(colour, "development.log", objects...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func commandLog(objects ...interface{}) {
|
func commandLog(objects ...interface{}) {
|
||||||
localLog(color.FgWhite, "commands.log", objects...)
|
localLog("commands.log", objects...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func localLog(colour color.Attribute, path string, objects ...interface{}) {
|
func localLog(path string, objects ...interface{}) {
|
||||||
if !*debuggingFlag {
|
if !*debuggingFlag {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -65,9 +60,9 @@ func localLog(colour color.Attribute, path string, objects ...interface{}) {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
log.SetOutput(f)
|
||||||
for _, object := range objects {
|
for _, object := range objects {
|
||||||
colorFunction := color.New(colour).SprintFunc()
|
log.Println(fmt.Sprint(object))
|
||||||
f.WriteString(colorFunction(fmt.Sprint(object)) + "\n")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,6 @@ func pushFileSnapshot(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handlePopFileSnapshot(g *gocui.Gui, v *gocui.View) error {
|
func handlePopFileSnapshot(g *gocui.Gui, v *gocui.View) error {
|
||||||
colorLog(color.FgCyan, "IM HERE")
|
|
||||||
if state.EditHistory.Len() == 0 {
|
if state.EditHistory.Len() == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user