Ejemplo n.º 1
0
// Log is intended to be called once at the end of your request handler, via defer
func (rl *respLogger) Log() {
	latency := time.Since(rl.startTime)
	if glog.V(2) {
		if !rl.hijacked {
			glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) %v%v%v [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.status, rl.statusStack, rl.addedInfo, rl.req.Header["User-Agent"], rl.req.RemoteAddr))
		} else {
			glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) hijacked [%s %s]", rl.req.Method, rl.req.RequestURI, latency, rl.req.Header["User-Agent"], rl.req.RemoteAddr))
		}
	}
}
Ejemplo n.º 2
0
func glogFileRangePairSideBySide(frp FileRangePair, optionalConfig *SideBySideConfig) {
	aRange, bRange := frp.ARange(), frp.BRange()
	mismatch := &BlockPair{
		AIndex:  aRange.FirstIndex(),
		ALength: aRange.Length(),
		BIndex:  bRange.FirstIndex(),
		BLength: bRange.Length(),
	}
	pairs := BlockPairs{mismatch}

	if optionalConfig == nil {
		optionalConfig = &SideBySideConfig{
			DisplayColumns:       128,
			DisplayLineNumbers:   true,
			WrapLongLines:        true,
			SpacesPerTab:         2,
			ContextLines:         0,
			ZeroBasedLineNumbers: true,
		}
	}

	// Maybe split if glog can't take too large a string?
	s := FormatSideBySideToString(aRange.File(), bRange.File(), pairs, false, *optionalConfig)
	glog.InfoDepth(1, "\n\n", s, "\n\n")
}
Ejemplo n.º 3
0
// Flush implements http.Flusher even if the underlying http.Writer doesn't implement it.
// Flush is used for streaming purposes and allows to flush buffered data to the client.
func (rl *respLogger) Flush() {
	if flusher, ok := rl.w.(http.Flusher); ok {
		flusher.Flush()
	} else if glog.V(2) {
		glog.InfoDepth(1, fmt.Sprintf("Unable to convert %+v into http.Flusher", rl.w))
	}
}
Ejemplo n.º 4
0
// Infof logs an info message with caller information.
func Infof(format string, args ...interface{}) {
	msg := format
	if len(args) > 0 {
		msg = fmt.Sprintf(format, args...)
	}

	log.InfoDepth(1, fmt.Sprintf("%s: %s", funcName(), msg))
}
Ejemplo n.º 5
0
func (r *diagnosticResultImpl) appendLogs(stackDepth int, entry ...log.Entry) {
	if r.logs == nil {
		r.logs = make([]log.Entry, 0)
	}
	r.logs = append(r.logs, entry...)
	// glog immediately for debugging when a diagnostic silently chokes
	for _, entry := range entry {
		if glog.V(glog.Level(6 - entry.Level.Level)) {
			glog.InfoDepth(stackDepth, entry.Message)
		}
	}
}
Ejemplo n.º 6
0
func glogSideBySide(aFile, bFile *File, pairs []*BlockPair, aIsPrimary bool,
	optionalConfig *SideBySideConfig) {
	if optionalConfig == nil {
		optionalConfig = &SideBySideConfig{
			DisplayColumns:       128,
			DisplayLineNumbers:   true,
			WrapLongLines:        true,
			SpacesPerTab:         2,
			ContextLines:         0,
			ZeroBasedLineNumbers: true,
		}
		if DefaultSideBySideConfig.DisplayColumns > optionalConfig.DisplayColumns {
			optionalConfig.DisplayColumns = DefaultSideBySideConfig.DisplayColumns
		}
	}
	// Maybe split if glog can't take too large a string?
	s := FormatSideBySideToString(aFile, bFile, pairs, aIsPrimary, *optionalConfig)
	glog.InfoDepth(1, "\n\n", s, "\n\n")
}
Ejemplo n.º 7
0
// Addf logs info immediately.
func (passthroughLogger) Addf(format string, data ...interface{}) {
	glog.InfoDepth(1, fmt.Sprintf(format, data...))
}
Ejemplo n.º 8
0
func (gl GLogger) Info(f string, a ...interface{}) {
	glog.InfoDepth(3, fmt.Sprintf(f, a...))
}
Ejemplo n.º 9
0
func (gl GLogger) Debug(f string, a ...interface{}) {
	// GLog doesn't have a "Debug" level, so use V(2) instead.
	if glog.V(2) {
		glog.InfoDepth(3, fmt.Sprintf(f, a...))
	}
}
Ejemplo n.º 10
0
func (g *glogger) Println(args ...interface{}) {
	glog.InfoDepth(2, fmt.Sprintln(args...))
}
Ejemplo n.º 11
0
// Infof implements log.Infof for a Suite.
func (t *Suite) Infof(format string, args ...interface{}) {
	log.InfoDepth(1, fmt.Sprintf(format, args...))
}
Ejemplo n.º 12
0
// Log is intended to be called once at the end of your request handler, via defer
func (rl *respLogger) Log() {
	latency := time.Since(rl.startTime)
	if glog.V(2) {
		glog.InfoDepth(1, fmt.Sprintf("%s %s: (%v) %v%v%v", rl.req.Method, rl.req.RequestURI, latency, rl.status, rl.statusStack, rl.addedInfo))
	}
}
Ejemplo n.º 13
0
// InfoDepth is part of the Logger interface.
func (cl *ConsoleLogger) InfoDepth(depth int, s string) {
	log.InfoDepth(1+depth, s)
}
Ejemplo n.º 14
0
func (Logger) Infof(format string, args ...interface{}) {
	glog.InfoDepth(3, fmt.Sprintf(format, args...))
}
Ejemplo n.º 15
0
// Infof is part of the Logger interface
func (cl ConsoleLogger) Infof(format string, v ...interface{}) {
	log.InfoDepth(2, fmt.Sprintf(format, v...))
}
Ejemplo n.º 16
0
Archivo: glg.go Proyecto: optimuse/ora
func (l gLgr) Infof(format string, v ...interface{}) {
	glog.InfoDepth(2, fmt.Sprintf(format, v...))
}
Ejemplo n.º 17
0
func (ll *LibraryLogger) Printf(format string, v ...interface{}) {
	if glog.V(ll.V) {
		glog.InfoDepth(1, ll.Prefix+fmt.Sprintf(format, v...))
	}
}
Ejemplo n.º 18
0
Archivo: glg.go Proyecto: optimuse/ora
func (l gLgr) Infoln(v ...interface{}) {
	glog.InfoDepth(2, v...)
}
Ejemplo n.º 19
0
func (g *glogger) Print(args ...interface{}) {
	glog.InfoDepth(2, args...)
}
Ejemplo n.º 20
0
func (l *logBridge) Write(b []byte) (n int, err error) {
	glog.InfoDepth(3, "go-marathon: "+string(b))
	return len(b), nil
}
Ejemplo n.º 21
0
func (g *glogger) Printf(format string, args ...interface{}) {
	glog.InfoDepth(2, fmt.Sprintf(format, args...))
}
Ejemplo n.º 22
0
func (ll *LibraryLogger) Println(v ...interface{}) {
	if glog.V(ll.V) {
		glog.InfoDepth(1, ll.Prefix+fmt.Sprintln(v...))
	}
}
Ejemplo n.º 23
0
func logAndRedirect(w http.ResponseWriter, r *http.Request, redirectTo, msg string) {
	http.Redirect(w, r, redirectTo, http.StatusTemporaryRedirect)
	glog.InfoDepth(1, msg)
}