Fix logger
This commit is contained in:
@@ -1,22 +1,26 @@
|
|||||||
package processor
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"modify/logger"
|
"modify/logger"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Initialize logger with ERROR level for tests
|
// Only modify logger in test mode
|
||||||
// to minimize noise in test output
|
// This checks if we're running under 'go test'
|
||||||
logger.Init(logger.LevelError)
|
if os.Getenv("GO_TESTING") == "1" || os.Getenv("TESTING") == "1" {
|
||||||
|
// Initialize logger with ERROR level for tests
|
||||||
|
// to minimize noise in test output
|
||||||
|
logger.Init(logger.LevelError)
|
||||||
|
|
||||||
// Optionally redirect logger output to discard
|
// Optionally redirect logger output to discard
|
||||||
// This prevents logger output from interfering with test output
|
// This prevents logger output from interfering with test output
|
||||||
disableTestLogs := os.Getenv("ENABLE_TEST_LOGS") != "1"
|
disableTestLogs := os.Getenv("ENABLE_TEST_LOGS") != "1"
|
||||||
if disableTestLogs {
|
if disableTestLogs {
|
||||||
// Create a new logger that writes to nowhere
|
// Create a new logger that writes to nowhere
|
||||||
silentLogger := logger.New(ioutil.Discard, "", 0)
|
silentLogger := logger.New(io.Discard, "", 0)
|
||||||
logger.DefaultLogger = silentLogger
|
logger.DefaultLogger = silentLogger
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user