type Output interface {
Printf(format string, vset ...interface{})
Flags() (flag int)
Prefix() (prefix string)
SetFlags(flag int)
SetPrefix(prefix string)
}
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
I would be curious what you think of github.com/go-kit/kit/log (and related "sub"-packages). See my talk about it's design here:
// Unstructured log.Printf("HTTP server listening on %s", addr) // Structured logger.Log("transport", "HTTP", "addr", addr, "msg", "listening")
func main() { log.WithFields(log.Fields{ "animal": "walrus", }).Info("A walrus appears") }
logger.Info("failed to fetch URL", // Structured context as strongly typed Field values. zap.String("url", url), zap.Int("attempt", 3), zap.Duration("backoff", time.Second), )
sugar := logger.Sugar() sugar.Infow("failed to fetch URL", // Structured context as loosely typed key-value pairs. "url", url, "attempt", 3, "backoff", time.Second, )
// kit logger = log.With(logger, "instance_id", 123) // logrus logger = logrus.WithFields(logrus.Fields{"instance_id": 123}) // zap logger = logger.With(zap.Int("instance_id", 123))
for i, v := range arr { logger := logger.With(zap.Int("itemIdx", i)) if err := v.Process(); err != nil { logger.Error("failed to process", zap.Object("error", err)) } }
Which is easy to override with any logger, is not tied to go-kit/log, but provides structured logging!
Even better: my libraries expose only the LogFunc: i.e.
--
That's a nice package with good design (and I've used it for a while). But I loose the info about where the error is happening.
//-----------------------------------------------------------------------------
var (
errNotAvailable = errors.New("N/A")
)
// Here .
func Here(skip ...int) (funcName, fileName string, fileLine int, callerErr error) {
sk := 1
if len(skip) > 0 && skip[0] > 1 {
sk = skip[0]
}
var pc uintptr
var ok bool
pc, fileName, fileLine, ok = runtime.Caller(sk)
if !ok {
callerErr = errNotAvailable
return
}
fn := runtime.FuncForPC(pc)
name := fn.Name()
ix := strings.LastIndex(name, ".")
if ix > 0 && (ix+1) < len(name) {
name = name[ix+1:]
}
funcName = name
nd, nf := filepath.Split(fileName)
fileName = filepath.Join(filepath.Base(nd), nf)
return
}
//-----------------------------------------------------------------------------
Sorry to but in but what happened to the whole logging initiative that was on going?Did I miss something about that? It seems very related to this.
Thx Chris, that's unfortunate it was many years until the Java world settled on something that worked in spite of having a built-in log package.
This is truly an area where we seem to repeat the mistakes of the past.
--