fmt.Fprintf(os.Stdout,"+++ %s is a slow test (took %v)\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgYellow)),fmt.Formatter(log.NewColoredValue(took,log.Bold,log.FgYellow)))
}else{
fmt.Fprintf(os.Stdout,"+++ %s is a slow tets (took %v)\n",t.Name(),took)
}
}
timer:=time.AfterFunc(slowFlush,func(){
iflog.CanColorStdout{
fmt.Fprintf(os.Stdout,"+++ %s ... still flushing after %v ...\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgRed)),slowFlush)
}else{
fmt.Fprintf(os.Stdout,"+++ %s ... still flushing after %v ...\n",t.Name(),slowFlush)
t.Errorf("Flushing queues failed with error %v",err)
}
timer.Stop()
flushTook:=time.Since(start)-took
ifflushTook>slowFlush{
iflog.CanColorStdout{
fmt.Fprintf(os.Stdout,"+++ %s had a slow clean-up flush (took %v)\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgRed)),fmt.Formatter(log.NewColoredValue(flushTook,log.Bold,log.FgRed)))
}else{
fmt.Fprintf(os.Stdout,"+++ %s had a slow clean-up flush (took %v)\n",t.Name(),flushTook)
}
}
_=writerCloser.Close()
}
}
// Printf takes a format and args and prints the string to os.Stdout
funcPrintf(formatstring,args...interface{}){
iflog.CanColorStdout{
fori:=0;i<len(args);i++{
args[i]=log.NewColoredValue(args[i])
}
}
fmt.Fprintf(os.Stdout,"\t"+format,args...)
}
// NewTestLogger creates a TestLogger as a log.LoggerProvider
funcNewTestLogger()log.LoggerProvider{
logger:=&TestLogger{}
logger.Colorize=log.CanColorStdout
logger.Level=log.TRACE
returnlogger
}
// Init inits connection writer with json config.
// json config only need key "level".
func(log*TestLogger)Init(configstring)error{
err:=json.Unmarshal([]byte(config),log)
iferr!=nil{
returnerr
}
log.NewWriterLogger(writerCloser)
returnnil
}
// Flush when log should be flushed
func(log*TestLogger)Flush(){
}
//ReleaseReopen does nothing
func(log*TestLogger)ReleaseReopen()error{
returnnil
}
// GetName returns the default name for this implementation