// Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT //go:build windows package logging import ( "io" "os" "golang.org/x/sys/windows" ) // checkIfTerminal also turns on virtual terminal processing, which the console needs to show colors. func checkIfTerminal(w io.Writer) bool { f, ok := w.(*os.File) if !ok { return false } handle := windows.Handle(f.Fd()) var mode uint32 if err := windows.GetConsoleMode(handle, &mode); err != nil { return false } return windows.SetConsoleMode(handle, mode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) == nil }