mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
feat(log): add segment info
This commit is contained in:
parent
1f59e3d420
commit
5bf3d613ae
|
@ -227,6 +227,7 @@ func (b *Block) Debug() (int, []*SegmentTiming) {
|
||||||
if segmentTiming.nameLength > largestSegmentNameLength {
|
if segmentTiming.nameLength > largestSegmentNameLength {
|
||||||
largestSegmentNameLength = segmentTiming.nameLength
|
largestSegmentNameLength = segmentTiming.nameLength
|
||||||
}
|
}
|
||||||
|
b.env.DebugF("Segment: %s", segmentTiming.name)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
segment.SetEnabled(b.env)
|
segment.SetEnabled(b.env)
|
||||||
segment.SetText()
|
segment.SetText()
|
||||||
|
|
|
@ -263,6 +263,7 @@ func (e *Engine) PrintDebug(startTime time.Time, version string) string {
|
||||||
e.write(log.Text("\nSegments:\n\n").Green().Bold().Plain().String())
|
e.write(log.Text("\nSegments:\n\n").Green().Bold().Plain().String())
|
||||||
// console title timing
|
// console title timing
|
||||||
titleStartTime := time.Now()
|
titleStartTime := time.Now()
|
||||||
|
e.Env.Debug("Segment: Title")
|
||||||
title := e.getTitleTemplateText()
|
title := e.getTitleTemplateText()
|
||||||
consoleTitleTiming := &SegmentTiming{
|
consoleTitleTiming := &SegmentTiming{
|
||||||
name: "ConsoleTitle",
|
name: "ConsoleTitle",
|
||||||
|
|
|
@ -48,15 +48,6 @@ func Debug(message string) {
|
||||||
printLn(debug, header, message)
|
printLn(debug, header, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DebugF(fn func() string) {
|
|
||||||
if !enabled {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fn2, line := funcSpec()
|
|
||||||
header := fmt.Sprintf("%s:%d", fn2, line)
|
|
||||||
printLn(debug, header, fn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func Error(err error) {
|
func Error(err error) {
|
||||||
if !enabled {
|
if !enabled {
|
||||||
return
|
return
|
||||||
|
|
|
@ -256,6 +256,10 @@ func (env *MockedEnvironment) Debug(message string) {
|
||||||
_ = env.Called(message)
|
_ = env.Called(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (env *MockedEnvironment) DebugF(format string, a ...any) {
|
||||||
|
_ = env.Called(format, a)
|
||||||
|
}
|
||||||
|
|
||||||
func (env *MockedEnvironment) Error(err error) {
|
func (env *MockedEnvironment) Error(err error) {
|
||||||
_ = env.Called(err)
|
_ = env.Called(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,7 @@ type Environment interface {
|
||||||
CursorPosition() (row, col int)
|
CursorPosition() (row, col int)
|
||||||
SystemInfo() (*SystemInfo, error)
|
SystemInfo() (*SystemInfo, error)
|
||||||
Debug(message string)
|
Debug(message string)
|
||||||
|
DebugF(format string, a ...any)
|
||||||
Error(err error)
|
Error(err error)
|
||||||
Trace(start time.Time, args ...string)
|
Trace(start time.Time, args ...string)
|
||||||
}
|
}
|
||||||
|
@ -379,12 +380,16 @@ func (env *Shell) Debug(message string) {
|
||||||
log.Debug(message)
|
log.Debug(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) Error(err error) {
|
func (env *Shell) DebugF(format string, a ...any) {
|
||||||
log.Error(err)
|
if !env.CmdFlags.Debug {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
message := fmt.Sprintf(format, a...)
|
||||||
|
log.Debug(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) debugF(fn func() string) {
|
func (env *Shell) Error(err error) {
|
||||||
log.DebugF(fn)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) Getenv(key string) string {
|
func (env *Shell) Getenv(key string) string {
|
||||||
|
@ -456,7 +461,7 @@ func (env *Shell) HasFilesInDir(dir, pattern string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
hasFilesInDir := len(matches) > 0
|
hasFilesInDir := len(matches) > 0
|
||||||
env.debugF(func() string { return strconv.FormatBool(hasFilesInDir) })
|
env.DebugF("%t", hasFilesInDir)
|
||||||
return hasFilesInDir
|
return hasFilesInDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,8 +493,9 @@ func (env *Shell) HasFolder(folder string) bool {
|
||||||
env.Debug("false")
|
env.Debug("false")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
env.debugF(func() string { return strconv.FormatBool(f.IsDir()) })
|
isDir := f.IsDir()
|
||||||
return f.IsDir()
|
env.DebugF("%t", isDir)
|
||||||
|
return isDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) ResolveSymlink(path string) (string, error) {
|
func (env *Shell) ResolveSymlink(path string) (string, error) {
|
||||||
|
@ -525,13 +531,7 @@ func (env *Shell) LsDir(path string) []fs.DirEntry {
|
||||||
env.Error(err)
|
env.Error(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
env.debugF(func() string {
|
env.DebugF("%v", entries)
|
||||||
var entriesStr string
|
|
||||||
for _, entry := range entries {
|
|
||||||
entriesStr += entry.Name() + "\n"
|
|
||||||
}
|
|
||||||
return entriesStr
|
|
||||||
})
|
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ func (env *Shell) isWriteable(folder string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
env.debugF(func() string { return ace.AccessMask.permissions() })
|
env.DebugF("%v", ace.AccessMask.permissions())
|
||||||
if ace.AccessMask.canWrite() {
|
if ace.AccessMask.canWrite() {
|
||||||
env.Debug("user has write access")
|
env.Debug("user has write access")
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue