Commit 61b2f1d3 authored by Joshua Gutow's avatar Joshua Gutow

testlog: Provide option to disable colored logging

parent 44b1ce37
......@@ -18,6 +18,7 @@
package testlog
import (
"os"
"runtime"
"strconv"
"strings"
......@@ -26,6 +27,14 @@ import (
"github.com/ethereum/go-ethereum/log"
)
var useColorInTestLog bool = true
func init() {
if os.Getenv("OP_TESTLOG_DISABLE_COLOR") == "true" {
useColorInTestLog = false
}
}
// Testing interface to log to. Some functions are marked as Helper function to log the call site accurately.
// Standard Go testing.TB implements this, as well as Hive and other Go-like test frameworks.
type Testing interface {
......@@ -75,7 +84,7 @@ func Logger(t Testing, level log.Lvl) log.Logger {
t: t,
l: log.New(),
mu: new(sync.Mutex),
h: &bufHandler{fmt: log.TerminalFormat(true)},
h: &bufHandler{fmt: log.TerminalFormat(useColorInTestLog)},
}
l.l.SetHandler(log.LvlFilterHandler(level, l.h))
return l
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment