code.gitea.io/gitea@v1.19.3/modules/log/console_other.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  //go:build !windows
     5  
     6  package log
     7  
     8  import (
     9  	"os"
    10  
    11  	"github.com/mattn/go-isatty"
    12  )
    13  
    14  func init() {
    15  	// when running gitea as a systemd unit with logging set to console, the output can not be colorized,
    16  	// otherwise it spams the journal / syslog with escape sequences like "#033[0m#033[32mcmd/web.go:102:#033[32m"
    17  	// this file covers non-windows platforms.
    18  	CanColorStdout = isatty.IsTerminal(os.Stdout.Fd())
    19  	CanColorStderr = isatty.IsTerminal(os.Stderr.Fd())
    20  }