Skip to content

Instantly share code, notes, and snippets.

@tj
Created January 14, 2016 14:06
Show Gist options
  • Save tj/299b6adce06bc0ff5839 to your computer and use it in GitHub Desktop.
Save tj/299b6adce06bc0ff5839 to your computer and use it in GitHub Desktop.
package main
import (
"errors"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/text"
)
func main() {
log.SetHandler(text.New(os.Stderr))
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})
for range time.Tick(time.Millisecond * 200) {
ctx.Info("upload")
ctx.Info("upload complete")
ctx.Warn("upload retry")
ctx.WithError(errors.New("unauthorized")).Error("upload failed")
ctx.Errorf("failed to upload %s", "img.png")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment