Repository: JanDeDobbeleer/oh-my-posh
Pull request #5881 (2024-11-13 16:13:07)

refactor(environment): remove logging via interface
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md].
- [x] The commit message follows the [conventional commits][cc] guidelines.
- [x] Tests for the changes have been added (for bug fixes / features).
- [x] Docs have been added/updated (for bug fixes / features).

<!---

Tips:

If you're not comfortable with working with Git,
we're working a guide (https://ohmyposh.dev/docs/contributing/git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/cli/config_export.go b/src/cli/config_export.go
index 6093402c..359ea1f3 100644
--- a/src/cli/config_export.go
+++ b/src/cli/config_export.go
@@ -40,7 +40,8 @@ Exports the current config to "~/new_config.omp.json" (in JSON format).`,
 			os.Exit(2)
 		}
 
-		cfg := config.Load(configFlag, shell.GENERIC, false)
+		configFile := config.Path(configFlag)
+		cfg := config.Load(configFile, shell.GENERIC, false)
 
 		validateExportFormat := func() {
 			format = strings.ToLower(format)
diff --git a/src/cli/config_export_image.go b/src/cli/config_export_image.go
index ceead33c..5150ffb7 100644
--- a/src/cli/config_export_image.go
+++ b/src/cli/config_export_image.go
@@ -50,10 +50,11 @@ Exports the config to an image file ~/mytheme.png.
 Exports the config to an image file using customized output options.`,
 	Args: cobra.NoArgs,
 	Run: func(_ *cobra.Command, _ []string) {
-		cfg := config.Load(configFlag, shell.GENERIC, false)
+		configFile := config.Path(configFlag)
+		cfg := config.Load(configFile, shell.GENERIC, false)
 
 		flags := &runtime.Flags{
-			Config:        configFlag,
+			Config:        configFile,
 			Shell:         shell.GENERIC,
 			TerminalWidth: 150,
 		}
diff --git a/src/cli/config_migrate.go b/src/cli/config_migrate.go
index dbe2a612..f794c5b5 100644
--- a/src/cli/config_migrate.go
+++ b/src/cli/config_migrate.go
@@ -40,10 +40,11 @@ Migrates the ~/myconfig.omp.json config file to TOML and writes the result to yo
 A backup of the current config can be found at ~/myconfig.omp.json.bak.`,
 	Args: cobra.NoArgs,
 	Run: func(_ *cobra.Command, _ []string) {
-		cfg := config.Load(configFlag, shell.GENERIC, true)
+		configFile := config.Path(configFlag)
+		cfg := config.Load(configFile, shell.GENERIC, true)
 
 		flags := &runtime.Flags{
-			Config:  configFlag,
+			Config:  configFile,
 			Migrate: true,
 		}
 
diff --git a/src/cli/config_migrate_glyphs.go b/src/cli/config_migrate_glyphs.go
index e93dae20..d65714d6 100644
--- a/src/cli/config_migrate_glyphs.go
+++ b/src/cli/config_migrate_glyphs.go
@@ -35,10 +35,11 @@ Migrates the ~/myconfig.omp.json config file's glyphs and writes the result to y
 A backup of the current config can be found at ~/myconfig.omp.json.bak.`,
 	Args: cobra.NoArgs,
 	Run: func(_ *cobra.Command, _ []string) {
-		cfg := config.Load(configFlag, shell.GENERIC, false)
+		configFile := config.Path(configFlag)
+		cfg := config.Load(configFile, shell.GENERIC, false)
 
 		flags := &runtime.Flags{
-			Config: configFlag,
+			Config: configFile,
 		}
 
 		env := &runtime.Terminal{}
diff --git a/src/cli/debug.go b/src/cli/debug.go
index 1001fdf2..d1a88eaa 100644
--- a/src/cli/debug.go
+++ b/src/cli/debug.go
@@ -6,6 +6,7 @@ import (
 
 	"github.com/jandedobbeleer/oh-my-posh/src/build"
 	"github.com/jandedobbeleer/oh-my-posh/src/config"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/prompt"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/template"
@@ -36,10 +37,14 @@ func createDebugCmd() *cobra.Command {
 				return
 			}
 
-			cfg := config.Load(configFlag, args[0], false)
+			log.Enable()
+			log.Debug("debug mode enabled")
+
+			configFile := config.Path(configFlag)
+			cfg := config.Load(configFile, args[0], false)
 
 			flags := &runtime.Flags{
-				Config: configFlag,
+				Config: configFile,
 				Debug:  true,
 				PWD:    pwd,
 				Shell:  args[0],
diff --git a/src/cli/init.go b/src/cli/init.go
index 66c6788a..f564c063 100644
--- a/src/cli/init.go
+++ b/src/cli/init.go
@@ -5,6 +5,7 @@ import (
 	"time"
 
 	"github.com/jandedobbeleer/oh-my-posh/src/config"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/shell"
 	"github.com/jandedobbeleer/oh-my-posh/src/template"
@@ -66,15 +67,19 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal
 
 func runInit(sh string) {
 	var startTime time.Time
+
 	if debug {
 		startTime = time.Now()
+		log.Enable()
+		log.Debug("debug mode enabled")
 	}
 
-	cfg := config.Load(configFlag, sh, false)
+	configFile := config.Path(configFlag)
+	cfg := config.Load(configFile, sh, false)
 
 	flags := &runtime.Flags{
 		Shell:  sh,
-		Config: configFlag,
+		Config: configFile,
 		Strict: strict,
 		Debug:  debug,
 	}
diff --git a/src/color/colors.go b/src/color/colors.go
index f8845d51..308ac457 100644
--- a/src/color/colors.go
+++ b/src/color/colors.go
@@ -8,6 +8,7 @@ import (
 
 	"github.com/gookit/color"
 	"github.com/jandedobbeleer/oh-my-posh/src/cache"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/template"
 )
@@ -164,7 +165,7 @@ func MakeColors(palette Palette, cacheEnabled bool, accentColor Ansi, env runtim
 }
 
 func (d *Defaults) SetAccentColor(env runtime.Environment, defaultColor Ansi) {
-	defer env.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	// get accent color from session cache first
 	if accent, OK := env.Session().Get("accent_color"); OK {
diff --git a/src/color/colors_darwin.go b/src/color/colors_darwin.go
index cd5c56b8..76713e89 100644
--- a/src/color/colors_darwin.go
+++ b/src/color/colors_darwin.go
@@ -4,19 +4,20 @@ import (
 	"errors"
 	"strconv"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 )
 
 func GetAccentColor(env runtime.Environment) (*RGB, error) {
 	output, err := env.RunCommand("defaults", "read", "-g", "AppleAccentColor")
 	if err != nil {
-		env.Error(err)
+		log.Error(err)
 		return nil, errors.New("unable to read accent color")
 	}
 
 	index, err := strconv.Atoi(output)
 	if err != nil {
-		env.Error(err)
+		log.Error(err)
 		return nil, errors.New("unable to parse accent color index")
 	}
 
diff --git a/src/color/colors_windows.go b/src/color/colors_windows.go
index 7092978c..4c029fc7 100644
--- a/src/color/colors_windows.go
+++ b/src/color/colors_windows.go
@@ -4,11 +4,12 @@ import (
 	"errors"
 	"time"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 )
 
 func GetAccentColor(env runtime.Environment) (*RGB, error) {
-	defer env.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if env == nil {
 		return nil, errors.New("unable to get color without environment")
diff --git a/src/config/load.go b/src/config/load.go
index f6c8dde6..d4609dc9 100644
--- a/src/config/load.go
+++ b/src/config/load.go
@@ -25,8 +25,6 @@ import (
 func Load(configFile, sh string, migrate bool) *Config {
 	defer log.Trace(time.Now())
 
-	configFile = Path(configFile)
-
 	cfg := loadConfig(configFile)
 
 	// only migrate automatically when the switch isn't set
diff --git a/src/config/segment.go b/src/config/segment.go
index bbc2b34a..f088eae4 100644
--- a/src/config/segment.go
+++ b/src/config/segment.go
@@ -9,6 +9,7 @@ import (
 
 	"github.com/jandedobbeleer/oh-my-posh/src/cache"
 	"github.com/jandedobbeleer/oh-my-posh/src/color"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
@@ -105,7 +106,7 @@ func (segment *Segment) Execute(env runtime.Environment) {
 		return
 	}
 
-	segment.env.DebugF("segment: %s", segment.Name())
+	log.Debugf("segment: %s", segment.Name())
 
 	if segment.isToggled() {
 		return
@@ -207,7 +208,7 @@ func (segment *Segment) isToggled() bool {
 	list := strings.Split(toggles, ",")
 	for _, toggle := range list {
 		if SegmentType(toggle) == segment.Type || toggle == segment.Alias {
-			segment.env.DebugF("segment toggled off: %s", segment.Name())
+			log.Debugf("segment toggled off: %s", segment.Name())
 			return true
 		}
 	}
@@ -227,7 +228,7 @@ func (segment *Segment) restoreCache() bool {
 
 	err := json.Unmarshal([]byte(data), &segment.writer)
 	if err != nil {
-		segment.env.Error(err)
+		log.Error(err)
 	}
 
 	segment.Enabled = true
@@ -243,7 +244,7 @@ func (segment *Segment) setCache() {
 
 	data, err := json.Marshal(segment.writer)
 	if err != nil {
-		segment.env.Error(err)
+		log.Error(err)
 		return
 	}
 
diff --git a/src/log/log.go b/src/log/log.go
index 61fa5bb6..ae88d4bb 100644
--- a/src/log/log.go
+++ b/src/log/log.go
@@ -45,6 +45,15 @@ func Debug(message ...string) {
 	printLn(debug, header, strings.Join(message, " "))
 }
 
+func Debugf(format string, args ...interface{}) {
+	if !enabled {
+		return
+	}
+
+	message := fmt.Sprintf(format, args...)
+	Debug(message)
+}
+
 func Error(err error) {
 	if !enabled {
 		return
diff --git a/src/prompt/debug.go b/src/prompt/debug.go
index 71e574d3..50f318b4 100644
--- a/src/prompt/debug.go
+++ b/src/prompt/debug.go
@@ -21,7 +21,7 @@ func (e *Engine) PrintDebug(startTime time.Time, version string) string {
 
 	// console title timing
 	titleStartTime := time.Now()
-	e.Env.Debug("segment: Title")
+	log.Debug("segment: Title")
 	consoleTitle := &config.Segment{
 		Alias:      "ConsoleTitle",
 		NameLength: 12,
diff --git a/src/prompt/engine.go b/src/prompt/engine.go
index 0647cebe..ab6f1ebe 100644
--- a/src/prompt/engine.go
+++ b/src/prompt/engine.go
@@ -462,6 +462,7 @@ func (e *Engine) rectifyTerminalWidth(diff int) {
 // given configuration options, and is ready to print any
 // of the prompt components.
 func New(flags *runtime.Flags) *Engine {
+	flags.Config = config.Path(flags.Config)
 	cfg := config.Load(flags.Config, flags.Shell, flags.Migrate)
 
 	env := &runtime.Terminal{}
diff --git a/src/runtime/environment.go b/src/runtime/environment.go
index 50fdd5cd..930fcc77 100644
--- a/src/runtime/environment.go
+++ b/src/runtime/environment.go
@@ -3,7 +3,6 @@ package runtime
 import (
 	"io"
 	"io/fs"
-	"time"
 
 	"github.com/jandedobbeleer/oh-my-posh/src/cache"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/battery"
@@ -68,10 +67,6 @@ type Environment interface {
 	Connection(connectionType ConnectionType) (*Connection, error)
 	CursorPosition() (row, col int)
 	SystemInfo() (*SystemInfo, error)
-	Debug(message string)
-	DebugF(format string, a ...any)
-	Error(err error)
-	Trace(start time.Time, args ...string)
 }
 
 type Flags struct {
diff --git a/src/runtime/networks_windows.go b/src/runtime/networks_windows.go
index 05843bd2..08d17f7b 100644
--- a/src/runtime/networks_windows.go
+++ b/src/runtime/networks_windows.go
@@ -7,6 +7,7 @@ import (
 	"time"
 	"unsafe"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"golang.org/x/sys/windows"
 )
 
@@ -180,7 +181,7 @@ func (term *Terminal) getConnections() []*Connection {
 			continue
 		}
 
-		term.DebugF("Found network interface: %s", alias)
+		log.Debugf("Found network interface: %s", alias)
 
 		network := &Connection{
 			Type:         connectionType,
@@ -201,7 +202,7 @@ func (term *Terminal) getConnections() []*Connection {
 }
 
 func (term *Terminal) wifiNetwork() (*Connection, error) {
-	term.Trace(time.Now())
+	log.Trace(time.Now())
 	// Open handle
 	var pdwNegotiatedVersion uint32
 	var phClientHandle uint32
@@ -252,7 +253,7 @@ func (term *Terminal) parseNetworkInterface(network *WLAN_INTERFACE_INFO, client
 		uintptr(unsafe.Pointer(&wlanAttr)),
 		uintptr(unsafe.Pointer(nil)))
 	if e != 0 {
-		term.Error(err)
+		log.Error(err)
 		return &info, err
 	}
 
@@ -261,7 +262,7 @@ func (term *Terminal) parseNetworkInterface(network *WLAN_INTERFACE_INFO, client
 	if ssid.uSSIDLength > 0 {
 		info.SSID = string(ssid.ucSSID[0:ssid.uSSIDLength])
 		info.Name = info.SSID
-		term.DebugF("Found wifi interface: %s", info.SSID)
+		log.Debugf("Found wifi interface: %s", info.SSID)
 	}
 
 	info.TransmitRate = uint64(wlanAttr.wlanAssociationAttributes.ulTxRate / 1024)
diff --git a/src/runtime/terminal.go b/src/runtime/terminal.go
index 5fee41cb..0e0cc5b3 100644
--- a/src/runtime/terminal.go
+++ b/src/runtime/terminal.go
@@ -41,7 +41,7 @@ type Terminal struct {
 }
 
 func (term *Terminal) Init(flags *Flags) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	term.CmdFlags = flags
 
@@ -49,11 +49,6 @@ func (term *Terminal) Init(flags *Flags) {
 		term.CmdFlags = &Flags{}
 	}
 
-	if term.CmdFlags.Debug {
-		log.Enable()
-		log.Debug("debug mode enabled")
-	}
-
 	if term.CmdFlags.Plain {
 		log.Plain()
 		log.Debug("plain mode enabled")
@@ -76,30 +71,10 @@ func (term *Terminal) Init(flags *Flags) {
 	}
 }
 
-func (term *Terminal) Trace(start time.Time, args ...string) {
-	log.Trace(start, args...)
-}
-
-func (term *Terminal) Debug(message string) {
-	log.Debug(message)
-}
-
-func (term *Terminal) DebugF(format string, a ...any) {
-	if !term.CmdFlags.Debug {
-		return
-	}
-	message := fmt.Sprintf(format, a...)
-	log.Debug(message)
-}
-
-func (term *Terminal) Error(err error) {
-	log.Error(err)
-}
-
 func (term *Terminal) Getenv(key string) string {
-	defer term.Trace(time.Now(), key)
+	defer log.Trace(time.Now(), key)
 	val := os.Getenv(key)
-	term.Debug(val)
+	log.Debug(val)
 	return val
 }
 
@@ -108,7 +83,7 @@ func (term *Terminal) Pwd() string {
 }
 
 func (term *Terminal) setPwd() {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	correctPath := func(pwd string) string {
 		if term.GOOS() != WINDOWS {
@@ -121,18 +96,18 @@ func (term *Terminal) setPwd() {
 
 	if term.CmdFlags != nil && term.CmdFlags.PWD != "" {
 		term.cwd = path.Clean(term.CmdFlags.PWD)
-		term.Debug(term.cwd)
+		log.Debug(term.cwd)
 		return
 	}
 
 	dir, err := os.Getwd()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return
 	}
 
 	term.cwd = correctPath(dir)
-	term.Debug(term.cwd)
+	log.Debug(term.cwd)
 }
 
 func (term *Terminal) HasFiles(pattern string) bool {
@@ -140,7 +115,7 @@ func (term *Terminal) HasFiles(pattern string) bool {
 }
 
 func (term *Terminal) HasFilesInDir(dir, pattern string) bool {
-	defer term.Trace(time.Now(), pattern)
+	defer log.Trace(time.Now(), pattern)
 
 	fileSystem := os.DirFS(dir)
 	var dirEntries []fs.DirEntry
@@ -153,8 +128,8 @@ func (term *Terminal) HasFilesInDir(dir, pattern string) bool {
 		var err error
 		dirEntries, err = fs.ReadDir(fileSystem, ".")
 		if err != nil {
-			term.Error(err)
-			term.Debug("false")
+			log.Error(err)
+			log.Debug("false")
 			return false
 		}
 
@@ -170,127 +145,127 @@ func (term *Terminal) HasFilesInDir(dir, pattern string) bool {
 
 		matchFileName, err := filepath.Match(pattern, strings.ToLower(match.Name()))
 		if err != nil {
-			term.Error(err)
-			term.Debug("false")
+			log.Error(err)
+			log.Debug("false")
 			return false
 		}
 
 		if matchFileName {
-			term.Debug("true")
+			log.Debug("true")
 			return true
 		}
 	}
 
-	term.Debug("false")
+	log.Debug("false")
 	return false
 }
 
 func (term *Terminal) HasFileInParentDirs(pattern string, depth uint) bool {
-	defer term.Trace(time.Now(), pattern, fmt.Sprint(depth))
+	defer log.Trace(time.Now(), pattern, fmt.Sprint(depth))
 	currentFolder := term.Pwd()
 
 	for c := 0; c < int(depth); c++ {
 		if term.HasFilesInDir(currentFolder, pattern) {
-			term.Debug("true")
+			log.Debug("true")
 			return true
 		}
 
 		if dir := filepath.Dir(currentFolder); dir != currentFolder {
 			currentFolder = dir
 		} else {
-			term.Debug("false")
+			log.Debug("false")
 			return false
 		}
 	}
-	term.Debug("false")
+	log.Debug("false")
 	return false
 }
 
 func (term *Terminal) HasFolder(folder string) bool {
-	defer term.Trace(time.Now(), folder)
+	defer log.Trace(time.Now(), folder)
 	f, err := os.Stat(folder)
 	if err != nil {
-		term.Debug("false")
+		log.Debug("false")
 		return false
 	}
 	isDir := f.IsDir()
-	term.DebugF("%t", isDir)
+	log.Debugf("%t", isDir)
 	return isDir
 }
 
 func (term *Terminal) ResolveSymlink(input string) (string, error) {
-	defer term.Trace(time.Now(), input)
+	defer log.Trace(time.Now(), input)
 	link, err := filepath.EvalSymlinks(input)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return "", err
 	}
-	term.Debug(link)
+	log.Debug(link)
 	return link, nil
 }
 
 func (term *Terminal) FileContent(file string) string {
-	defer term.Trace(time.Now(), file)
+	defer log.Trace(time.Now(), file)
 	if !filepath.IsAbs(file) {
 		file = filepath.Join(term.Pwd(), file)
 	}
 
 	content, err := os.ReadFile(file)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return ""
 	}
 
 	fileContent := string(content)
-	term.Debug(fileContent)
+	log.Debug(fileContent)
 
 	return fileContent
 }
 
 func (term *Terminal) LsDir(input string) []fs.DirEntry {
-	defer term.Trace(time.Now(), input)
+	defer log.Trace(time.Now(), input)
 
 	entries, err := os.ReadDir(input)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil
 	}
 
-	term.DebugF("%v", entries)
+	log.Debugf("%v", entries)
 	return entries
 }
 
 func (term *Terminal) User() string {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	user := os.Getenv("USER")
 	if user == "" {
 		user = os.Getenv("USERNAME")
 	}
-	term.Debug(user)
+	log.Debug(user)
 	return user
 }
 
 func (term *Terminal) Host() (string, error) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	if len(term.host) != 0 {
 		return term.host, nil
 	}
 
 	hostName, err := os.Hostname()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return "", err
 	}
 
 	hostName = cleanHostName(hostName)
-	term.Debug(hostName)
+	log.Debug(hostName)
 	term.host = hostName
 
 	return hostName, nil
 }
 
 func (term *Terminal) GOOS() string {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return runtime.GOOS
 }
 
@@ -299,7 +274,7 @@ func (term *Terminal) Home() string {
 }
 
 func (term *Terminal) RunCommand(command string, args ...string) (string, error) {
-	defer term.Trace(time.Now(), append([]string{command}, args...)...)
+	defer log.Trace(time.Now(), append([]string{command}, args...)...)
 
 	if cacheCommand, ok := term.cmdCache.Get(command); ok {
 		command = cacheCommand
@@ -307,15 +282,15 @@ func (term *Terminal) RunCommand(command string, args ...string) (string, error)
 
 	output, err := cmd.Run(command, args...)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 	}
 
-	term.Debug(output)
+	log.Debug(output)
 	return output, err
 }
 
 func (term *Terminal) RunShellCommand(shell, command string) string {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if out, err := term.RunCommand(shell, "-c", command); err == nil {
 		return out
@@ -325,25 +300,25 @@ func (term *Terminal) RunShellCommand(shell, command string) string {
 }
 
 func (term *Terminal) CommandPath(command string) string {
-	defer term.Trace(time.Now(), command)
+	defer log.Trace(time.Now(), command)
 	if cmdPath, ok := term.cmdCache.Get(command); ok {
-		term.Debug(cmdPath)
+		log.Debug(cmdPath)
 		return cmdPath
 	}
 
 	cmdPath, err := exec.LookPath(command)
 	if err == nil {
 		term.cmdCache.Set(command, cmdPath)
-		term.Debug(cmdPath)
+		log.Debug(cmdPath)
 		return cmdPath
 	}
 
-	term.Error(err)
+	log.Error(err)
 	return ""
 }
 
 func (term *Terminal) HasCommand(command string) bool {
-	defer term.Trace(time.Now(), command)
+	defer log.Trace(time.Now(), command)
 
 	if cmdPath := term.CommandPath(command); cmdPath != "" {
 		return true
@@ -353,21 +328,21 @@ func (term *Terminal) HasCommand(command string) bool {
 }
 
 func (term *Terminal) StatusCodes() (int, string) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if term.CmdFlags.Shell != CMD || !term.CmdFlags.NoExitCode {
 		return term.CmdFlags.ErrorCode, term.CmdFlags.PipeStatus
 	}
 
 	errorCode := term.Getenv("=ExitCode")
-	term.Debug(errorCode)
+	log.Debug(errorCode)
 	term.CmdFlags.ErrorCode, _ = strconv.Atoi(errorCode)
 
 	return term.CmdFlags.ErrorCode, term.CmdFlags.PipeStatus
 }
 
 func (term *Terminal) ExecutionTime() float64 {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	if term.CmdFlags.ExecutionTime < 0 {
 		return 0
 	}
@@ -375,34 +350,34 @@ func (term *Terminal) ExecutionTime() float64 {
 }
 
 func (term *Terminal) Flags() *Flags {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return term.CmdFlags
 }
 
 func (term *Terminal) Shell() string {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	if len(term.CmdFlags.Shell) != 0 {
 		return term.CmdFlags.Shell
 	}
-	term.Debug("no shell name provided in flags, trying to detect it")
+	log.Debug("no shell name provided in flags, trying to detect it")
 	pid := os.Getppid()
 	p, _ := process.NewProcess(int32(pid))
 	name, err := p.Name()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return UNKNOWN
 	}
-	term.Debug("process name: " + name)
+	log.Debug("process name: " + name)
 	// this is used for when scoop creates a shim, see
 	// https://github.com/jandedobbeleer/oh-my-posh/issues/2806
 	executable, _ := os.Executable()
 	if name == executable {
 		p, _ = p.Parent()
 		name, err = p.Name()
-		term.Debug("parent process name: " + name)
+		log.Debug("parent process name: " + name)
 	}
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return UNKNOWN
 	}
 	// Cache the shell value to speed things up.
@@ -424,7 +399,7 @@ func (term *Terminal) unWrapError(err error) error {
 }
 
 func (term *Terminal) HTTPRequest(targetURL string, body io.Reader, timeout int, requestModifiers ...http.RequestModifier) ([]byte, error) {
-	defer term.Trace(time.Now(), targetURL)
+	defer log.Trace(time.Now(), targetURL)
 
 	ctx, cncl := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(timeout))
 	defer cncl()
@@ -440,12 +415,12 @@ func (term *Terminal) HTTPRequest(targetURL string, body io.Reader, timeout int,
 
 	if term.CmdFlags.Debug {
 		dump, _ := httputil.DumpRequestOut(request, true)
-		term.Debug(string(dump))
+		log.Debug(string(dump))
 	}
 
 	response, err := http.HTTPClient.Do(request)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, term.unWrapError(err)
 	}
 
@@ -453,7 +428,7 @@ func (term *Terminal) HTTPRequest(targetURL string, body io.Reader, timeout int,
 	if response.StatusCode < 200 || response.StatusCode >= 300 {
 		message := "HTTP status code " + strconv.Itoa(response.StatusCode)
 		err := errors.New(message)
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
@@ -461,17 +436,17 @@ func (term *Terminal) HTTPRequest(targetURL string, body io.Reader, timeout int,
 
 	responseBody, err := io.ReadAll(response.Body)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
-	term.Debug(string(responseBody))
+	log.Debug(string(responseBody))
 
 	return responseBody, nil
 }
 
 func (term *Terminal) HasParentFilePath(parent string, followSymlinks bool) (*FileInfo, error) {
-	defer term.Trace(time.Now(), parent)
+	defer log.Trace(time.Now(), parent)
 
 	pwd := term.Pwd()
 	if followSymlinks {
@@ -500,13 +475,13 @@ func (term *Terminal) HasParentFilePath(parent string, followSymlinks bool) (*Fi
 			continue
 		}
 
-		term.Error(err)
+		log.Error(err)
 		return nil, errors.New("no match at root level")
 	}
 }
 
 func (term *Terminal) StackCount() int {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if term.CmdFlags.StackCount < 0 {
 		return 0
@@ -524,7 +499,7 @@ func (term *Terminal) Session() cache.Cache {
 }
 
 func (term *Terminal) Close() {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	term.clearCacheFiles()
 	term.deviceCache.Close()
 	term.sessionCache.Close()
@@ -537,12 +512,12 @@ func (term *Terminal) clearCacheFiles() {
 
 	deletedFiles, err := cache.Clear(cache.Path(), false)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return
 	}
 
 	for _, file := range deletedFiles {
-		term.DebugF("removed cache file: %s", file)
+		log.Debugf("removed cache file: %s", file)
 	}
 }
 
@@ -556,7 +531,7 @@ func (term *Terminal) DirMatchesOneOf(dir string, regexes []string) (match bool)
 	// for the time being until we figure out what the actual root cause is
 	defer func() {
 		if err := recover(); err != nil {
-			term.Error(errors.New("panic"))
+			log.Error(errors.New("panic"))
 			match = false
 		}
 	}()
@@ -595,7 +570,7 @@ func dirMatchesOneOf(dir, home, goos string, regexes []string) bool {
 }
 
 func (term *Terminal) setPromptCount() {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	var count int
 	if val, found := term.Session().Get(cache.PROMPTCOUNTCACHE); found {
diff --git a/src/runtime/terminal_darwin.go b/src/runtime/terminal_darwin.go
index 1e730f01..0e434e0d 100644
--- a/src/runtime/terminal_darwin.go
+++ b/src/runtime/terminal_darwin.go
@@ -6,6 +6,7 @@ import (
 	"strings"
 	"time"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/battery"
@@ -34,13 +35,13 @@ func (term *Terminal) parseBatteryOutput(output string) (*battery.Info, error) {
 	matches := regex.FindNamedRegexMatch(`(?P<PERCENTAGE>[0-9]{1,3})%; (?P<STATE>[a-zA-Z\s]+);`, output)
 	if len(matches) != 2 {
 		err := errors.New("Unable to find battery state based on output")
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 	var percentage int
 	var err error
 	if percentage, err = strconv.Atoi(matches["PERCENTAGE"]); err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, errors.New("Unable to parse battery percentage")
 	}
 	return &battery.Info{
@@ -50,10 +51,10 @@ func (term *Terminal) parseBatteryOutput(output string) (*battery.Info, error) {
 }
 
 func (term *Terminal) BatteryState() (*battery.Info, error) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	output, err := term.RunCommand("pmset", "-g", "batt")
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 	if !strings.Contains(output, "Battery") {
diff --git a/src/runtime/terminal_unix.go b/src/runtime/terminal_unix.go
index ce4cff39..7cdbf08b 100644
--- a/src/runtime/terminal_unix.go
+++ b/src/runtime/terminal_unix.go
@@ -9,6 +9,7 @@ import (
 	"time"
 
 	"github.com/jandedobbeleer/oh-my-posh/src/cache"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/shirou/gopsutil/v3/host"
 	mem "github.com/shirou/gopsutil/v3/mem"
 	terminal "github.com/wayneashleyberry/terminal-dimensions"
@@ -16,7 +17,7 @@ import (
 )
 
 func (term *Terminal) Root() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return os.Geteuid() == 0
 }
 
@@ -25,10 +26,10 @@ func (term *Terminal) QueryWindowTitles(_, _ string) (string, error) {
 }
 
 func (term *Terminal) IsWsl() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	const key = "is_wsl"
 	if val, found := term.Cache().Get(key); found {
-		term.Debug(val)
+		log.Debug(val)
 		return val == "true"
 	}
 
@@ -38,13 +39,13 @@ func (term *Terminal) IsWsl() bool {
 	}()
 
 	val = term.HasCommand("wslpath")
-	term.Debug(strconv.FormatBool(val))
+	log.Debug(strconv.FormatBool(val))
 
 	return val
 }
 
 func (term *Terminal) IsWsl2() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	if !term.IsWsl() {
 		return false
 	}
@@ -53,21 +54,21 @@ func (term *Terminal) IsWsl2() bool {
 }
 
 func (term *Terminal) IsCygwin() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return false
 }
 
 func (term *Terminal) TerminalWidth() (int, error) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if term.CmdFlags.TerminalWidth > 0 {
-		term.DebugF("terminal width: %d", term.CmdFlags.TerminalWidth)
+		log.Debugf("terminal width: %d", term.CmdFlags.TerminalWidth)
 		return term.CmdFlags.TerminalWidth, nil
 	}
 
 	width, err := terminal.Width()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 	}
 
 	// fetch width from the environment variable
@@ -75,20 +76,20 @@ func (term *Terminal) TerminalWidth() (int, error) {
 	if width == 0 {
 		i, err := strconv.Atoi(term.Getenv("COLUMNS"))
 		if err != nil {
-			term.Error(err)
+			log.Error(err)
 		}
 		width = uint(i)
 	}
 
 	term.CmdFlags.TerminalWidth = int(width)
-	term.DebugF("terminal width: %d", term.CmdFlags.TerminalWidth)
+	log.Debugf("terminal width: %d", term.CmdFlags.TerminalWidth)
 	return term.CmdFlags.TerminalWidth, err
 }
 
 func (term *Terminal) Platform() string {
 	const key = "environment_platform"
 	if val, found := term.Cache().Get(key); found {
-		term.Debug(val)
+		log.Debug(val)
 		return val
 	}
 
@@ -99,7 +100,7 @@ func (term *Terminal) Platform() string {
 
 	if wsl := term.Getenv("WSL_DISTRO_NAME"); len(wsl) != 0 {
 		platform = strings.Split(strings.ToLower(wsl), "-")[0]
-		term.Debug(platform)
+		log.Debug(platform)
 		return platform
 	}
 
@@ -112,7 +113,7 @@ func (term *Terminal) Platform() string {
 		}
 	}
 
-	term.Debug(platform)
+	log.Debug(platform)
 	return platform
 }
 
@@ -144,7 +145,7 @@ func (term *Terminal) ConvertToLinuxPath(input string) string {
 }
 
 func (term *Terminal) DirIsWritable(input string) bool {
-	defer term.Trace(time.Now(), input)
+	defer log.Trace(time.Now(), input)
 	return unix.Access(input, unix.W_OK) == nil
 }
 
@@ -161,7 +162,7 @@ func (term *Terminal) Memory() (*Memory, error) {
 	m := &Memory{}
 	memStat, err := mem.VirtualMemory()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 	m.PhysicalTotalMemory = memStat.Total
@@ -170,7 +171,7 @@ func (term *Terminal) Memory() (*Memory, error) {
 	m.PhysicalPercentUsed = memStat.UsedPercent
 	swapStat, err := mem.SwapMemory()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 	}
 	m.SwapTotalMemory = swapStat.Total
 	m.SwapFreeMemory = swapStat.Free
diff --git a/src/runtime/terminal_windows.go b/src/runtime/terminal_windows.go
index 75020e61..0330777a 100644
--- a/src/runtime/terminal_windows.go
+++ b/src/runtime/terminal_windows.go
@@ -8,13 +8,14 @@ import (
 	"time"
 
 	"github.com/Azure/go-ansiterm/winterm"
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/path"
 	"golang.org/x/sys/windows"
 	"golang.org/x/sys/windows/registry"
 )
 
 func (term *Terminal) Root() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	var sid *windows.SID
 
 	// Although this looks scary, it is directly copied from the
@@ -29,7 +30,7 @@ func (term *Terminal) Root() bool {
 		0, 0, 0, 0, 0, 0,
 		&sid)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return false
 	}
 	defer func() {
@@ -43,7 +44,7 @@ func (term *Terminal) Root() bool {
 
 	member, err := token.IsMember(sid)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return false
 	}
 
@@ -51,51 +52,51 @@ func (term *Terminal) Root() bool {
 }
 
 func (term *Terminal) QueryWindowTitles(processName, windowTitleRegex string) (string, error) {
-	defer term.Trace(time.Now(), windowTitleRegex)
+	defer log.Trace(time.Now(), windowTitleRegex)
 	title, err := queryWindowTitles(processName, windowTitleRegex)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 	}
 	return title, err
 }
 
 func (term *Terminal) IsWsl() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return false
 }
 
 func (term *Terminal) IsWsl2() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return false
 }
 
 func (term *Terminal) IsCygwin() bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return len(term.Getenv("OSTYPE")) > 0
 }
 
 func (term *Terminal) TerminalWidth() (int, error) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 
 	if term.CmdFlags.TerminalWidth > 0 {
-		term.DebugF("terminal width: %d", term.CmdFlags.TerminalWidth)
+		log.Debugf("terminal width: %d", term.CmdFlags.TerminalWidth)
 		return term.CmdFlags.TerminalWidth, nil
 	}
 
 	handle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return 0, err
 	}
 
 	info, err := winterm.GetConsoleScreenBufferInfo(uintptr(handle))
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return 0, err
 	}
 
 	term.CmdFlags.TerminalWidth = int(info.Size.X)
-	term.DebugF("terminal width: %d", term.CmdFlags.TerminalWidth)
+	log.Debugf("terminal width: %d", term.CmdFlags.TerminalWidth)
 	return term.CmdFlags.TerminalWidth, nil
 }
 
@@ -113,7 +114,7 @@ func (term *Terminal) Platform() string {
 //
 // Returns a variant type if successful; nil and an error if not.
 func (term *Terminal) WindowsRegistryKeyValue(input string) (*WindowsRegistryValue, error) {
-	term.Trace(time.Now(), input)
+	log.Trace(time.Now(), input)
 
 	// Format:
 	// "HKLM\Software\Microsoft\Windows NT\CurrentVersion\EditionID"
@@ -130,7 +131,7 @@ func (term *Terminal) WindowsRegistryKeyValue(input string) (*WindowsRegistryVal
 	rootKey, regPath, found := strings.Cut(input, `\`)
 	if !found {
 		err := fmt.Errorf("Error, malformed registry path: '%s'", input)
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
@@ -156,19 +157,19 @@ func (term *Terminal) WindowsRegistryKeyValue(input string) (*WindowsRegistryVal
 		key = windows.HKEY_USERS
 	default:
 		err := fmt.Errorf("Error, unknown registry key: '%s", rootKey)
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
 	k, err := registry.OpenKey(key, regPath, registry.READ)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
 	_, valType, err := k.GetValue(regKey, nil)
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
@@ -194,7 +195,7 @@ func (term *Terminal) WindowsRegistryKeyValue(input string) (*WindowsRegistryVal
 		return nil, errors.New(errorLogMsg)
 	}
 
-	term.Debug(fmt.Sprintf("%s(%s): %s", regKey, regValue.ValueType, regValue.String))
+	log.Debug(fmt.Sprintf("%s(%s): %s", regKey, regValue.ValueType, regValue.String))
 	return regValue, nil
 }
 
@@ -211,7 +212,7 @@ func (term *Terminal) ConvertToLinuxPath(input string) string {
 }
 
 func (term *Terminal) DirIsWritable(input string) bool {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	return term.isWriteable(input)
 }
 
@@ -230,6 +231,6 @@ func (term *Terminal) Connection(connectionType ConnectionType) (*Connection, er
 		}
 	}
 
-	term.Error(fmt.Errorf("Network type '%s' not found", connectionType))
+	log.Error(fmt.Errorf("Network type '%s' not found", connectionType))
 	return nil, &NotImplemented{}
 }
diff --git a/src/runtime/terminal_windows_nix.go b/src/runtime/terminal_windows_nix.go
index 3f8c4de1..82a7abf2 100644
--- a/src/runtime/terminal_windows_nix.go
+++ b/src/runtime/terminal_windows_nix.go
@@ -5,14 +5,15 @@ package runtime
 import (
 	"time"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/battery"
 )
 
 func (term *Terminal) BatteryState() (*battery.Info, error) {
-	defer term.Trace(time.Now())
+	defer log.Trace(time.Now())
 	info, err := battery.Get()
 	if err != nil {
-		term.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 	return info, nil
diff --git a/src/runtime/win32_windows.go b/src/runtime/win32_windows.go
index c054c6b4..f86bf45a 100644
--- a/src/runtime/win32_windows.go
+++ b/src/runtime/win32_windows.go
@@ -8,6 +8,7 @@ import (
 	"syscall"
 	"unsafe"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 
 	"golang.org/x/sys/windows"
@@ -223,20 +224,20 @@ func (env *Terminal) isWriteable(folder string) bool {
 
 	if err != nil {
 		// unable to get current user
-		env.Error(err)
+		log.Error(err)
 		return false
 	}
 
 	si, err := windows.GetNamedSecurityInfo(folder, windows.SE_FILE_OBJECT, windows.DACL_SECURITY_INFORMATION)
 	if err != nil {
-		env.Error(err)
+		log.Error(err)
 		return false
 	}
 
 	dacl, _, err := si.DACL()
 	if err != nil || dacl == nil {
 		// no dacl implies full access
-		env.Debug("no dacl")
+		log.Debug("no dacl")
 		return true
 	}
 
@@ -248,32 +249,32 @@ func (env *Terminal) isWriteable(folder string) bool {
 
 		ret, _, _ := procGetAce.Call(uintptr(unsafe.Pointer(dacl)), uintptr(i), uintptr(unsafe.Pointer(&ace)))
 		if ret == 0 {
-			env.Debug("no ace found")
+			log.Debug("no ace found")
 			return false
 		}
 
 		aceSid := (*windows.SID)(unsafe.Pointer(&ace.SidStart))
 
 		if !cu.isMemberOf(aceSid) {
-			env.Debug("not current user or in group")
+			log.Debug("not current user or in group")
 			continue
 		}
 
-		env.Debug(fmt.Sprintf("current user is member of %s", aceSid.String()))
+		log.Debug(fmt.Sprintf("current user is member of %s", aceSid.String()))
 
 		// this gets priority over the other access types
 		if ace.AceType == ACCESS_DENIED_ACE_TYPE {
-			env.Debug("ACCESS_DENIED_ACE_TYPE")
+			log.Debug("ACCESS_DENIED_ACE_TYPE")
 			return false
 		}
 
-		env.DebugF("%v", ace.AccessMask.permissions())
+		log.Debugf("%v", ace.AccessMask.permissions())
 		if ace.AccessMask.canWrite() {
-			env.Debug("user has write access")
+			log.Debug("user has write access")
 			return true
 		}
 	}
-	env.Debug("no write access")
+	log.Debug("no write access")
 	return false
 }
 
@@ -299,7 +300,7 @@ func (env *Terminal) Memory() (*Memory, error) {
 	memStat.Length = uint32(unsafe.Sizeof(memStat))
 	r0, _, err := globalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memStat)))
 	if r0 == 0 {
-		env.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 	return &Memory{
diff --git a/src/segments/argocd.go b/src/segments/argocd.go
index 27a638d3..4350f3c7 100644
--- a/src/segments/argocd.go
+++ b/src/segments/argocd.go
@@ -6,6 +6,7 @@ import (
 	"path"
 	"strings"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/spf13/pflag"
 	"gopkg.in/yaml.v3"
 )
@@ -45,7 +46,7 @@ func (a *Argocd) Enabled() bool {
 	configPath := a.getConfigPath()
 	succeeded, err := a.parseConfig(configPath)
 	if err != nil {
-		a.env.Error(err)
+		log.Error(err)
 		return false
 	}
 	return succeeded
@@ -83,7 +84,7 @@ func (a *Argocd) parseConfig(file string) (bool, error) {
 	var data ArgocdConfig
 	err := yaml.Unmarshal([]byte(config), &data)
 	if err != nil {
-		a.env.Error(err)
+		log.Error(err)
 		return false, errors.New(argocdInvalidYaml)
 	}
 	a.Name = data.CurrentContext
diff --git a/src/segments/azd.go b/src/segments/azd.go
index 9221caf0..b595b21a 100644
--- a/src/segments/azd.go
+++ b/src/segments/azd.go
@@ -4,6 +4,8 @@ import (
 	"encoding/json"
 	"path/filepath"
 	"strings"
+
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 )
 
 type Azd struct {
@@ -33,7 +35,7 @@ func (t *Azd) Enabled() bool {
 	}
 
 	if len(parentFilePath) == 0 {
-		t.env.Debug("no .azure folder found in parent directories")
+		log.Debug("no .azure folder found in parent directories")
 		return false
 	}
 
diff --git a/src/segments/carbon_intensity.go b/src/segments/carbon_intensity.go
index afc61cb6..d0ac4d93 100644
--- a/src/segments/carbon_intensity.go
+++ b/src/segments/carbon_intensity.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 )
 
@@ -64,7 +65,7 @@ func (d *CarbonIntensity) Enabled() bool {
 	err := d.setStatus()
 
 	if err != nil {
-		d.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/firebase.go b/src/segments/firebase.go
index 76174928..d83b2ee4 100644
--- a/src/segments/firebase.go
+++ b/src/segments/firebase.go
@@ -5,6 +5,8 @@ import (
 	"errors"
 	"path/filepath"
 	"strings"
+
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 )
 
 const (
@@ -29,13 +31,13 @@ func (f *Firebase) Enabled() bool {
 	cfgDir := filepath.Join(f.env.Home(), ".config", "configstore")
 	configFile, err := f.getActiveConfig(cfgDir)
 	if err != nil {
-		f.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
 	data, err := f.getFirebaseData(configFile)
 	if err != nil {
-		f.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/gcp.go b/src/segments/gcp.go
index a2270931..d8de200a 100644
--- a/src/segments/gcp.go
+++ b/src/segments/gcp.go
@@ -4,6 +4,7 @@ import (
 	"errors"
 	"path"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 
 	"gopkg.in/ini.v1"
@@ -29,7 +30,7 @@ func (g *Gcp) Enabled() bool {
 	cfgDir := g.getConfigDirectory()
 	configFile, err := g.getActiveConfig(cfgDir)
 	if err != nil {
-		g.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
@@ -37,13 +38,13 @@ func (g *Gcp) Enabled() bool {
 	cfg := g.env.FileContent(cfgpath)
 
 	if len(cfg) == 0 {
-		g.env.Error(errors.New("config file is empty"))
+		log.Error(errors.New("config file is empty"))
 		return false
 	}
 
 	data, err := ini.Load([]byte(cfg))
 	if err != nil {
-		g.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/git.go b/src/segments/git.go
index 9ace75bc..7c0b16c6 100644
--- a/src/segments/git.go
+++ b/src/segments/git.go
@@ -8,6 +8,7 @@ import (
 	"strings"
 	"time"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
@@ -401,7 +402,7 @@ func (g *Git) hasWorktree(gitdir *runtime.FileInfo) bool {
 	matches := regex.FindNamedRegexMatch(`^gitdir: (?P<dir>.*)$`, content)
 
 	if len(matches) == 0 {
-		g.env.Debug("no matches found, directory isn't a worktree")
+		log.Debug("no matches found, directory isn't a worktree")
 		return false
 	}
 
diff --git a/src/segments/lastfm.go b/src/segments/lastfm.go
index 2a73d9fa..818f3c37 100644
--- a/src/segments/lastfm.go
+++ b/src/segments/lastfm.go
@@ -5,6 +5,7 @@ import (
 	"errors"
 	"fmt"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 )
 
@@ -54,7 +55,7 @@ func (d *LastFM) Enabled() bool {
 	err := d.setStatus()
 
 	if err != nil {
-		d.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/nba.go b/src/segments/nba.go
index 8e3f84cd..a2a18b1b 100644
--- a/src/segments/nba.go
+++ b/src/segments/nba.go
@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"time"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 )
 
@@ -292,17 +293,17 @@ func (nba *Nba) getResult() (*NBAData, error) {
 
 	httpTimeout := nba.props.GetInt(properties.HTTPTimeout, properties.DefaultHTTPTimeout)
 
-	nba.env.Debug("fetching available data for " + teamName)
+	log.Debug("fetching available data for " + teamName)
 
 	data, err := nba.getAvailableGameData(teamName, httpTimeout)
 	if err != nil {
-		nba.env.Error(errors.Join(err, fmt.Errorf("unable to get data for team %s", teamName)))
+		log.Error(errors.Join(err, fmt.Errorf("unable to get data for team %s", teamName)))
 		return nil, err
 	}
 
 	if !data.GameStatus.Valid() {
 		err := fmt.Errorf("%d is not a valid game status", data.GameStatus)
-		nba.env.Error(err)
+		log.Error(err)
 		return nil, err
 	}
 
diff --git a/src/segments/owm.go b/src/segments/owm.go
index f4188045..a5ab3a55 100644
--- a/src/segments/owm.go
+++ b/src/segments/owm.go
@@ -7,6 +7,7 @@ import (
 	"math"
 	"net/url"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 )
 
@@ -53,7 +54,7 @@ func (d *Owm) Enabled() bool {
 	err := d.setStatus()
 
 	if err != nil {
-		d.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/path.go b/src/segments/path.go
index 99dcf8ab..144704b0 100644
--- a/src/segments/path.go
+++ b/src/segments/path.go
@@ -6,6 +6,7 @@ import (
 	"strconv"
 	"strings"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
@@ -249,13 +250,13 @@ func (pt *Path) getMaxWidth() int {
 
 	text, err := tmpl.Render()
 	if err != nil {
-		pt.env.Error(err)
+		log.Error(err)
 		return 0
 	}
 
 	value, err := strconv.Atoi(text)
 	if err != nil {
-		pt.env.Error(err)
+		log.Error(err)
 		return 0
 	}
 
@@ -281,7 +282,7 @@ func (pt *Path) getFolderSeparator() string {
 
 	text, err := tmpl.Render()
 	if err != nil {
-		pt.env.Error(err)
+		log.Error(err)
 	}
 
 	if len(text) == 0 {
@@ -574,7 +575,7 @@ func (pt *Path) setMappedLocations() {
 
 		location, err := tmpl.Render()
 		if err != nil {
-			pt.env.Error(err)
+			log.Error(err)
 		}
 
 		if len(location) == 0 {
diff --git a/src/segments/posh_git.go b/src/segments/posh_git.go
index b340d4c0..c10cf32b 100644
--- a/src/segments/posh_git.go
+++ b/src/segments/posh_git.go
@@ -4,6 +4,8 @@ import (
 	"encoding/json"
 	"fmt"
 	"strings"
+
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 )
 
 const (
@@ -46,14 +48,14 @@ func (s *GitStatus) parsePoshGitStatus(p *poshGitStatus) {
 func (g *Git) hasPoshGitStatus() bool {
 	envStatus := g.env.Getenv(poshGitEnv)
 	if len(envStatus) == 0 {
-		g.env.Error(fmt.Errorf("%s environment variable not set, do you have the posh-git module installed?", poshGitEnv))
+		log.Error(fmt.Errorf("%s environment variable not set, do you have the posh-git module installed?", poshGitEnv))
 		return false
 	}
 
 	var posh poshGit
 	err := json.Unmarshal([]byte(envStatus), &posh)
 	if err != nil {
-		g.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/project.go b/src/segments/project.go
index c2c1daae..c4f2777a 100644
--- a/src/segments/project.go
+++ b/src/segments/project.go
@@ -7,6 +7,7 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 	"golang.org/x/exp/slices"
@@ -256,7 +257,7 @@ func (n *Project) getDotnetProject(_ ProjectItem) *ProjectData {
 	}
 
 	if len(target) == 0 {
-		n.env.Error(fmt.Errorf("cannot extract TFM from %s project file", name))
+		log.Error(fmt.Errorf("cannot extract TFM from %s project file", name))
 	}
 
 	return &ProjectData{
diff --git a/src/segments/pulumi.go b/src/segments/pulumi.go
index 24d16dad..b1b8df78 100644
--- a/src/segments/pulumi.go
+++ b/src/segments/pulumi.go
@@ -7,6 +7,7 @@ import (
 	"fmt"
 	"path/filepath"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/path"
 	"gopkg.in/yaml.v3"
@@ -58,7 +59,7 @@ func (p *Pulumi) Enabled() bool {
 
 	err := p.getProjectName()
 	if err != nil {
-		p.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
@@ -75,7 +76,7 @@ func (p *Pulumi) Enabled() bool {
 
 func (p *Pulumi) getPulumiStackName() {
 	if len(p.Name) == 0 || len(p.workspaceSHA1) == 0 {
-		p.env.Debug("pulumi project name or workspace sha1 is empty")
+		log.Debug("pulumi project name or workspace sha1 is empty")
 		return
 	}
 
@@ -94,11 +95,11 @@ func (p *Pulumi) getPulumiStackName() {
 	var pulumiWorkspaceSpec pulumiWorkSpaceFileSpec
 	err := json.Unmarshal([]byte(workspaceCacheFileContent), &pulumiWorkspaceSpec)
 	if err != nil {
-		p.env.Error(fmt.Errorf("pulumi workspace file decode error"))
+		log.Error(fmt.Errorf("pulumi workspace file decode error"))
 		return
 	}
 
-	p.env.DebugF("pulumi stack name: %s", pulumiWorkspaceSpec.Stack)
+	log.Debugf("pulumi stack name: %s", pulumiWorkspaceSpec.Stack)
 	p.Stack = pulumiWorkspaceSpec.Stack
 }
 
@@ -130,7 +131,7 @@ func (p *Pulumi) getProjectName() error {
 	}
 
 	if err != nil {
-		p.env.Error(err)
+		log.Error(err)
 		return nil
 	}
 
@@ -146,7 +147,7 @@ func (p *Pulumi) sha1HexString(s string) string {
 
 	_, err := h.Write([]byte(s))
 	if err != nil {
-		p.env.Error(err)
+		log.Error(err)
 		return ""
 	}
 
@@ -155,14 +156,14 @@ func (p *Pulumi) sha1HexString(s string) string {
 
 func (p *Pulumi) getPulumiAbout() {
 	if len(p.Stack) == 0 {
-		p.env.Error(fmt.Errorf("pulumi stack name is empty, use `fetch_stack` property to enable stack fetching"))
+		log.Error(fmt.Errorf("pulumi stack name is empty, use `fetch_stack` property to enable stack fetching"))
 		return
 	}
 
 	aboutOutput, err := p.env.RunCommand("pulumi", "about", "--json")
 
 	if err != nil {
-		p.env.Error(fmt.Errorf("unable to get pulumi about output"))
+		log.Error(fmt.Errorf("unable to get pulumi about output"))
 		return
 	}
 
@@ -172,12 +173,12 @@ func (p *Pulumi) getPulumiAbout() {
 
 	err = json.Unmarshal([]byte(aboutOutput), &about)
 	if err != nil {
-		p.env.Error(fmt.Errorf("pulumi about output decode error"))
+		log.Error(fmt.Errorf("pulumi about output decode error"))
 		return
 	}
 
 	if about.Backend == nil {
-		p.env.Debug("pulumi about backend is not set")
+		log.Debug("pulumi about backend is not set")
 		return
 	}
 
diff --git a/src/segments/sitecore.go b/src/segments/sitecore.go
index cd780e4a..a053f8b6 100644
--- a/src/segments/sitecore.go
+++ b/src/segments/sitecore.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"path"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 )
 
@@ -32,14 +33,14 @@ type UserConfig struct {
 
 func (s *Sitecore) Enabled() bool {
 	if !s.env.HasFiles(sitecoreFileName) || !s.env.HasFilesInDir(sitecoreFolderName, userFileName) {
-		s.env.Debug("sitecore cli configuration files were not found")
+		log.Debug("sitecore cli configuration files were not found")
 		return false
 	}
 
 	var userConfig, err = getUserConfig(s)
 
 	if err != nil {
-		s.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
@@ -48,7 +49,7 @@ func (s *Sitecore) Enabled() bool {
 	displayDefault := s.props.GetBool(properties.DisplayDefault, true)
 
 	if !displayDefault && s.EndpointName == defaultEnpointName {
-		s.env.Debug("displaying of the default environment is turned off")
+		log.Debug("displaying of the default environment is turned off")
 		return false
 	}
 
diff --git a/src/segments/talosctl.go b/src/segments/talosctl.go
index 95e29fff..df7feff7 100644
--- a/src/segments/talosctl.go
+++ b/src/segments/talosctl.go
@@ -4,6 +4,7 @@ import (
 	"errors"
 	"path/filepath"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"gopkg.in/yaml.v3"
 )
 
@@ -21,13 +22,13 @@ func (t *TalosCTL) Enabled() bool {
 	cfgDir := filepath.Join(t.env.Home(), ".talos")
 	configFile, err := t.getActiveConfig(cfgDir)
 	if err != nil {
-		t.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
 	err = yaml.Unmarshal([]byte(configFile), t)
 	if err != nil {
-		t.env.Error(err)
+		log.Error(err)
 		return false
 	}
 
diff --git a/src/segments/umbraco.go b/src/segments/umbraco.go
index 1c4dc901..7d9dd592 100644
--- a/src/segments/umbraco.go
+++ b/src/segments/umbraco.go
@@ -4,6 +4,8 @@ import (
 	"encoding/xml"
 	"path/filepath"
 	"strings"
+
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 )
 
 type Umbraco struct {
@@ -40,7 +42,7 @@ func (u *Umbraco) Enabled() bool {
 	}
 
 	if len(location) == 0 {
-		u.env.Debug("no umbraco folder found in parent directories")
+		log.Debug("no umbraco folder found in parent directories")
 		return false
 	}
 
@@ -85,7 +87,7 @@ func (u *Umbraco) Template() string {
 func (u *Umbraco) TryFindModernUmbraco(configPath string) bool {
 	// Check the passed in filepath is not empty
 	if len(configPath) == 0 {
-		u.env.Debug("no configPath provided")
+		log.Debug("no configPath provided")
 		return false
 	}
 
@@ -102,7 +104,7 @@ func (u *Umbraco) TryFindModernUmbraco(configPath string) bool {
 	err := xml.Unmarshal([]byte(contents), &csProjPackages)
 
 	if err != nil {
-		u.env.Debug(err.Error())
+		log.Debug(err.Error())
 	}
 
 	// Loop over all the package references
@@ -121,7 +123,7 @@ func (u *Umbraco) TryFindModernUmbraco(configPath string) bool {
 func (u *Umbraco) TryFindLegacyUmbraco(configPath string) bool {
 	// Check the passed in filepath is not empty
 	if len(configPath) == 0 {
-		u.env.Debug("no configPath provided")
+		log.Debug("no configPath provided")
 		return false
 	}
 
@@ -138,7 +140,7 @@ func (u *Umbraco) TryFindLegacyUmbraco(configPath string) bool {
 	err := xml.Unmarshal([]byte(contents), &webConfigAppSettings)
 
 	if err != nil {
-		u.env.Debug(err.Error())
+		log.Debug(err.Error())
 	}
 
 	// Loop over all the package references
diff --git a/src/segments/unity.go b/src/segments/unity.go
index 89c0a107..7e0b321c 100644
--- a/src/segments/unity.go
+++ b/src/segments/unity.go
@@ -6,6 +6,7 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/jandedobbeleer/oh-my-posh/src/log"
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/regex"
 )
@@ -24,7 +25,7 @@ func (u *Unity) Template() string {
 func (u *Unity) Enabled() bool {
 	unityVersion, err := u.GetUnityVersion()
 	if err != nil {
-		u.env.Error(err)
+		log.Error(err)
 		return false
 	}
 	if len(unityVersion) == 0 {
@@ -34,7 +35,7 @@ func (u *Unity) Enabled() bool {
 
 	csharpVersion, err := u.GetCSharpVersion()
 	if err != nil {
-		u.env.Error(err)
+		log.Error(err)
 	}
 	u.CSharpVersion = csharpVersion
 
@@ -44,12 +45,12 @@ func (u *Unity) Enabled() bool {
 func (u *Unity) GetUnityVersion() (string, error) {
 	projectDir, err := u.env.HasParentFilePath("ProjectSettings", false)
 	if err != nil {
-		u.env.Debug("no ProjectSettings parent folder found")
+		log.Debug("no ProjectSettings parent folder found")
 		return "", err
 	}
 
 	if !u.env.HasFilesInDir(projectDir.Path, "ProjectVersion.txt") {
-		u.env.Debug("no ProjectVersion.txt file found")
+		log.Debug("no ProjectVersion.txt file found")
 		return "", err
 	}
 
@@ -114,7 +115,7 @@ func (u *Unity) GetCSharpVersion() (version string, err error) {
 		return csharpVersion, nil
 	}
 
-	u.env.Debug(fmt.Sprintf("Unity version %s doesn't exist in the map", shortUnityVersion))
+	log.Debug(fmt.Sprintf("Unity version %s doesn't exist in the map", shortUnityVersion))
 	return u.GetCSharpVersionFromWeb(shortUnityVersion)
 }
 


Test patch:
diff --git a/src/color/colors_test.go b/src/color/colors_test.go
index 6e399331..473c8299 100644
--- a/src/color/colors_test.go
+++ b/src/color/colors_test.go
@@ -10,8 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/jandedobbeleer/oh-my-posh/src/template"
-
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestGetAnsiFromColorString(t *testing.T) {
@@ -45,8 +43,6 @@ func TestGetAnsiFromColorString(t *testing.T) {
 func TestMakeColors(t *testing.T) {
 	env := &mock.Environment{}
 
-	env.On("Trace", testify_.Anything, testify_.Anything).Return(nil)
-
 	c := &cache_.Cache{}
 	c.On("Get", "accent_color").Return("", true)
 	env.On("Session").Return(c)
diff --git a/src/runtime/http/oauth_test.go b/src/runtime/http/oauth_test.go
index c7a2b287..7b4e8ec4 100644
--- a/src/runtime/http/oauth_test.go
+++ b/src/runtime/http/oauth_test.go
@@ -135,7 +135,6 @@ func TestOauthResult(t *testing.T) {
 		env.On("Cache").Return(cache)
 		env.On("HTTPRequest", url).Return([]byte(tc.JSONResponse), tc.Error)
 		env.On("HTTPRequest", tokenURL).Return([]byte(tc.TokenResponse), tc.Error)
-		env.On("Error", testify_.Anything)
 
 		oauth := &OAuthRequest{
 			AccessTokenKey:  accessTokenKey,
diff --git a/src/segments/argocd_test.go b/src/segments/argocd_test.go
index 8926cfdc..fc8ea66c 100644
--- a/src/segments/argocd_test.go
+++ b/src/segments/argocd_test.go
@@ -9,7 +9,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 const (
@@ -160,7 +159,6 @@ users:
 	for _, tc := range cases {
 		env := new(mock.Environment)
 		env.On("FileContent", configFile).Return(tc.Config)
-		env.On("Error", testify_.Anything).Return()
 
 		argocd := &Argocd{
 			base: base{
@@ -257,7 +255,6 @@ servers:
 		env.On("Home").Return(poshHome)
 		env.On("Getenv", argocdOptsEnv).Return(tc.Opts)
 		env.On("FileContent", configFile).Return(tc.Config)
-		env.On("Error", testify_.Anything).Return()
 		env.On("Flags").Return(&runtime.Flags{})
 
 		argocd := &Argocd{}
diff --git a/src/segments/azd_test.go b/src/segments/azd_test.go
index a9291ae4..91533346 100644
--- a/src/segments/azd_test.go
+++ b/src/segments/azd_test.go
@@ -10,7 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestAzdSegment(t *testing.T) {
@@ -36,7 +35,6 @@ func TestAzdSegment(t *testing.T) {
 
 	for _, tc := range cases {
 		env := new(mock.Environment)
-		env.On("Debug", testify_.Anything)
 		env.On("Flags").Return(&runtime.Flags{})
 
 		if tc.IsInited {
diff --git a/src/segments/carbon_intensity_test.go b/src/segments/carbon_intensity_test.go
index d9d64b61..802facdc 100644
--- a/src/segments/carbon_intensity_test.go
+++ b/src/segments/carbon_intensity_test.go
@@ -10,7 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 const (
@@ -226,7 +225,6 @@ func TestCarbonIntensitySegmentSingle(t *testing.T) {
 		}
 
 		env.On("HTTPRequest", CARBONINTENSITYURL).Return([]byte(jsonResponse), responseError)
-		env.On("Error", testify_.Anything)
 		env.On("Flags").Return(&runtime.Flags{})
 
 		d := &CarbonIntensity{}
diff --git a/src/segments/firebase_test.go b/src/segments/firebase_test.go
index 05817c27..9b00cacf 100644
--- a/src/segments/firebase_test.go
+++ b/src/segments/firebase_test.go
@@ -7,7 +7,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestFirebaseSegment(t *testing.T) {
@@ -59,7 +58,6 @@ func TestFirebaseSegment(t *testing.T) {
 		env.On("Pwd").Return(tc.ActivePath)
 		fcPath := filepath.Join("home", ".config", "configstore", "firebase-tools.json")
 		env.On("FileContent", fcPath).Return(tc.ActiveConfig)
-		env.On("Error", testify_.Anything).Return()
 
 		f := &Firebase{}
 		f.Init(properties.Map{}, env)
@@ -104,7 +102,6 @@ func TestGetFirebaseActiveConfig(t *testing.T) {
 		configPath := filepath.Join("home", ".config", "configstore")
 		contentPath := filepath.Join(configPath, "firebase-tools.json")
 		env.On("FileContent", contentPath).Return(tc.ActiveConfig)
-		env.On("Error", testify_.Anything).Return()
 
 		f := &Firebase{}
 		f.Init(properties.Map{}, env)
diff --git a/src/segments/gcp_test.go b/src/segments/gcp_test.go
index 2072585a..e21a4681 100644
--- a/src/segments/gcp_test.go
+++ b/src/segments/gcp_test.go
@@ -9,7 +9,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestGcpSegment(t *testing.T) {
@@ -58,7 +57,6 @@ func TestGcpSegment(t *testing.T) {
 		env.On("FileContent", fcPath).Return(tc.ActiveConfig)
 		cfgpath := path.Join("config", "configurations", "config_production")
 		env.On("FileContent", cfgpath).Return(tc.CfgData)
-		env.On("Error", testify_.Anything).Return()
 
 		g := &Gcp{}
 		g.Init(properties.Map{}, env)
diff --git a/src/segments/lastfm_test.go b/src/segments/lastfm_test.go
index e904df8d..2c02c6fe 100644
--- a/src/segments/lastfm_test.go
+++ b/src/segments/lastfm_test.go
@@ -8,7 +8,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 const (
@@ -61,7 +60,6 @@ func TestLFMSegmentSingle(t *testing.T) {
 		}
 
 		env.On("HTTPRequest", LFMAPIURL).Return([]byte(tc.APIJSONResponse), tc.Error)
-		env.On("Error", testify_.Anything)
 
 		lfm := &LastFM{}
 		lfm.Init(props, env)
diff --git a/src/segments/nba_test.go b/src/segments/nba_test.go
index 359017e8..c80c2d25 100644
--- a/src/segments/nba_test.go
+++ b/src/segments/nba_test.go
@@ -10,7 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func getTestData(file string) string {
@@ -80,8 +79,6 @@ func TestNBASegment(t *testing.T) {
 			DaysOffset: tc.DaysOffset,
 		}
 
-		env.On("Error", testify_.Anything)
-		env.On("Debug", testify_.Anything)
 		env.On("HTTPRequest", NBAScoreURL).Return([]byte(tc.JSONResponse), tc.Error)
 
 		// Add all the daysOffset to the http request responses
diff --git a/src/segments/owm_test.go b/src/segments/owm_test.go
index ff2c160e..b9a73bd7 100644
--- a/src/segments/owm_test.go
+++ b/src/segments/owm_test.go
@@ -10,7 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 const (
@@ -82,7 +81,6 @@ func TestOWMSegmentSingle(t *testing.T) {
 		location := url.QueryEscape(tc.Location)
 		testURL := fmt.Sprintf(OWMWEATHERAPIURL, location)
 		env.On("HTTPRequest", testURL).Return([]byte(tc.WeatherJSONResponse), tc.Error)
-		env.On("Error", testify_.Anything)
 
 		o := &Owm{}
 		o.Init(props, env)
diff --git a/src/segments/path_test.go b/src/segments/path_test.go
index 53bae5c4..89150aae 100644
--- a/src/segments/path_test.go
+++ b/src/segments/path_test.go
@@ -122,8 +122,6 @@ func TestAgnosterPathStyles(t *testing.T) {
 		}
 		env.On("Shell").Return(tc.Shell)
 
-		env.On("DebugF", testify_.Anything, testify_.Anything).Return(nil)
-
 		displayCygpath := tc.Cygwin
 		if displayCygpath {
 			env.On("RunCommand", "cygpath", []string{"-u", tc.Pwd}).Return(tc.Cygpath, tc.CygpathError)
@@ -360,7 +358,6 @@ func TestGetFolderSeparator(t *testing.T) {
 
 	for _, tc := range cases {
 		env := new(mock.Environment)
-		env.On("Error", testify_.Anything)
 		env.On("Shell").Return(shell.GENERIC)
 
 		template.Cache = &cache.Template{
@@ -481,7 +478,6 @@ func TestGetMaxWidth(t *testing.T) {
 
 	for _, tc := range cases {
 		env := new(mock.Environment)
-		env.On("Error", testify_.Anything).Return(nil)
 		env.On("Getenv", "MAX_WIDTH").Return("120")
 		env.On("Shell").Return(shell.BASH)
 
diff --git a/src/segments/posh_git_test.go b/src/segments/posh_git_test.go
index ed0711b4..99f66ad2 100644
--- a/src/segments/posh_git_test.go
+++ b/src/segments/posh_git_test.go
@@ -8,7 +8,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestPoshGitSegment(t *testing.T) {
@@ -187,7 +186,6 @@ func TestPoshGitSegment(t *testing.T) {
 		env.On("Getenv", poshGitEnv).Return(tc.PoshGitJSON)
 		env.On("Home").Return("/Users/bill")
 		env.On("GOOS").Return(runtime.LINUX)
-		env.On("Error", testify_.Anything)
 		env.On("RunCommand", "git", []string{"-C", "", "--no-optional-locks", "-c", "core.quotepath=false",
 			"-c", "color.status=false", "remote", "get-url", "origin"}).Return("github.com/cli", nil)
 
diff --git a/src/segments/project_test.go b/src/segments/project_test.go
index 2711dfd1..e157cab2 100644
--- a/src/segments/project_test.go
+++ b/src/segments/project_test.go
@@ -487,7 +487,6 @@ func TestDotnetProject(t *testing.T) {
 			},
 		})
 		env.On("FileContent", tc.FileName).Return(tc.ProjectContents)
-		env.On("Error", testify_.Anything)
 		pkg := &Project{}
 		pkg.Init(properties.Map{}, env)
 		assert.Equal(t, tc.ExpectedEnabled, pkg.Enabled(), tc.Case)
diff --git a/src/segments/pulumi_test.go b/src/segments/pulumi_test.go
index 0f07acf3..2bcc035d 100644
--- a/src/segments/pulumi_test.go
+++ b/src/segments/pulumi_test.go
@@ -10,7 +10,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/path"
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestPulumi(t *testing.T) {
@@ -166,9 +165,6 @@ description: A Console App
 		pwd := "/home/foobar/Work/oh-my-posh/pulumi/projects/awesome-project"
 		env.On("Pwd").Return(pwd)
 		env.On("Home").Return(filepath.Clean("/home/foobar"))
-		env.On("Error", testify_.Anything)
-		env.On("Debug", testify_.Anything)
-		env.On("DebugF", testify_.Anything, testify_.Anything)
 
 		env.On("HasFiles", pulumiYAML).Return(len(tc.YAMLConfig) > 0)
 		env.On("FileContent", pulumiYAML).Return(tc.YAMLConfig, nil)
diff --git a/src/segments/sitecore_test.go b/src/segments/sitecore_test.go
index 2ed3568d..34489097 100644
--- a/src/segments/sitecore_test.go
+++ b/src/segments/sitecore_test.go
@@ -8,7 +8,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestSitecoreSegment(t *testing.T) {
@@ -89,8 +88,6 @@ func TestSitecoreSegment(t *testing.T) {
 		env.On("HasFiles", "sitecore.json").Return(tc.SitecoreFileExists)
 		env.On("HasFilesInDir", ".sitecore", "user.json").Return(tc.UserFileExists)
 		env.On("FileContent", path.Join(".sitecore", "user.json")).Return(tc.UserFileContent)
-		env.On("Debug", testify_.Anything)
-		env.On("Error", testify_.Anything)
 
 		props := properties.Map{
 			properties.DisplayDefault: tc.DisplayDefault,
diff --git a/src/segments/talosctl_test.go b/src/segments/talosctl_test.go
index a0e468db..05fc3ef4 100644
--- a/src/segments/talosctl_test.go
+++ b/src/segments/talosctl_test.go
@@ -7,7 +7,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestTalosctlSegment(t *testing.T) {
@@ -44,7 +43,6 @@ func TestTalosctlSegment(t *testing.T) {
 		env.On("Home").Return("home")
 		fcPath := filepath.Join("home", ".talos", "config")
 		env.On("FileContent", fcPath).Return(tc.ActiveConfig)
-		env.On("Error", testify_.Anything).Return()
 
 		talos := TalosCTL{}
 		talos.Init(properties.Map{}, env)
@@ -82,7 +80,6 @@ func TestGetTalosctlActiveConfig(t *testing.T) {
 		configPath := filepath.Join("home", ".talos")
 		contentPath := filepath.Join(configPath, "config")
 		env.On("FileContent", contentPath).Return(tc.ActiveConfig)
-		env.On("Error", testify_.Anything).Return()
 
 		talos := TalosCTL{}
 		talos.Init(properties.Map{}, env)
diff --git a/src/segments/umbraco_test.go b/src/segments/umbraco_test.go
index 743b6f40..309c472a 100644
--- a/src/segments/umbraco_test.go
+++ b/src/segments/umbraco_test.go
@@ -12,7 +12,6 @@ import (
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
 
 	"github.com/stretchr/testify/assert"
-	testify_ "github.com/stretchr/testify/mock"
 )
 
 func TestUmbracoSegment(t *testing.T) {
@@ -137,7 +136,6 @@ func TestUmbracoSegment(t *testing.T) {
 		env.On("FileContent", filepath.Join(umbracoProjectDirectory, "MyProject.csproj")).Return(sampleCSProj)
 		env.On("FileContent", filepath.Join(umbracoProjectDirectory, "ANonUmbracoProject.csproj")).Return(sampleNonUmbracoCSProj)
 		env.On("FileContent", filepath.Join(umbracoProjectDirectory, "web.config")).Return(sampleWebConfig)
-		env.On("Debug", testify_.Anything)
 
 		if tc.HasUmbracoFolder {
 			fileInfo := &runtime.FileInfo{
diff --git a/src/segments/unity_test.go b/src/segments/unity_test.go
index 0005c769..ae27ec10 100644
--- a/src/segments/unity_test.go
+++ b/src/segments/unity_test.go
@@ -5,8 +5,6 @@ import (
 	"path/filepath"
 	"testing"
 
-	testify_ "github.com/stretchr/testify/mock"
-
 	"github.com/jandedobbeleer/oh-my-posh/src/properties"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
 	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
@@ -69,8 +67,6 @@ func TestUnitySegment(t *testing.T) {
 
 	for _, tc := range cases {
 		env := new(mock.Environment)
-		env.On("Error", testify_.Anything).Return()
-		env.On("Debug", testify_.Anything)
 
 		err := errors.New("no match at root level")
 		var projectDir *runtime.FileInfo
@@ -158,8 +154,6 @@ func TestUnitySegmentCSharpWebRequest(t *testing.T) {
 
 	for _, tc := range cases {
 		env := new(mock.Environment)
-		env.On("Error", testify_.Anything).Return()
-		env.On("Debug", testify_.Anything)
 
 		err := errors.New("no match at root level")
 		var projectDir *runtime.FileInfo