Created
January 14, 2016 14:06
-
-
Save tj/c64e33e7f27f84c3557d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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