Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created March 4, 2015 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lestrrat/281b5ecc69d3b3b9f12b to your computer and use it in GitHub Desktop.
Save lestrrat/281b5ecc69d3b3b9f12b to your computer and use it in GitHub Desktop.
とうとう脳内デバッグだけ追えるgoroutineの並列度を突破したのでトレース用のPrintfをあちこちに仕込むことにした
package peco
import (
"log"
"os"
)
type traceLogger interface {
Printf(string, ...interface{})
}
type nullTraceLogger struct{}
func (ntl nullTraceLogger) Printf(_ string, _ ...interface{}) {}
var tracer traceLogger = nullTraceLogger{}
func init() {
if os.Getenv("PECO_TRACE") != "" {
tracer = log.New(os.Stderr, "", log.LstdFlags)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment