Ejemplo n.º 1
0
Archivo: logger.go Proyecto: shkw/gae
// TODO(riannucci): prefix with caller's code location.
func (gl *loggerImpl) LogCall(l logging.Level, calldepth int, format string, args []interface{}) {
	if gl.aeCtx == nil || !logging.IsLogging(gl.ic, l) {
		return
	}

	var logf func(context.Context, string, ...interface{})
	switch l {
	case logging.Debug:
		logf = log.Debugf
	case logging.Info:
		logf = log.Infof
	case logging.Warning:
		logf = log.Warningf

	case logging.Error:
		fallthrough
	default:
		logf = log.Errorf
	}

	fields := logging.GetFields(gl.ic)
	if len(fields) > 0 {
		logf(gl.aeCtx, "%s :: %s", fmt.Sprintf(format, args...), fields.String())
	} else {
		logf(gl.aeCtx, format, args...)
	}
}
Ejemplo n.º 2
0
func (li *loggerImpl) LogCall(l logging.Level, calldepth int, format string, args []interface{}) {
	// Append the fields to the format string.
	if li.c != nil {
		if !logging.IsLogging(li.c, l) {
			return
		}

		if fields := logging.GetFields(li.c); len(fields) > 0 {
			format = formatWithFields(format, fields, args)
			args = nil
		}
	}

	li.Lock()
	defer li.Unlock()

	li.l.ExtraCalldepth = (calldepth + 1)
	switch l {
	case logging.Debug:
		li.l.Debug(format, args...)
	case logging.Info:
		li.l.Info(format, args...)
	case logging.Warning:
		li.l.Warning(format, args...)
	case logging.Error:
		li.l.Error(format, args...)
	}
}
Ejemplo n.º 3
0
func (l *boundCloudLogger) LogCall(level log.Level, calldepth int, f string, args []interface{}) {
	if len(f) == 0 || !log.IsLogging(l.ctx, level) {
		return
	}

	l.logger.logC <- &logEntry{
		timestamp: clock.Now(l.ctx),
		level:     level,
		fmt:       f,
		args:      args,
		fields:    log.GetFields(l.ctx),
	}
}
Ejemplo n.º 4
0
func (g *gaeLoggerImpl) og(l logging.Level, logf func(string, ...interface{}),
	format string, args []interface{}) {
	if g.c != nil {
		if !logging.IsLogging(g.c, l) {
			return
		}
	}

	fields := logging.GetFields(g.c)
	if len(fields) > 0 {
		logf("%s ctx%s", fmt.Sprintf(format, args...), fields.FieldString(true))
	} else {
		logf(format, args...)
	}
}