logginghandler/vendor/github.com/apex/log
Marvin Preuss d095180eb4
All checks were successful
continuous-integration/drone/push Build is passing
build: uses go modules for tool handling
2022-01-14 13:51:56 +01:00
..
handlers/cli build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
.gitignore build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
context.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
default.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
doc.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
entry.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
go.mod build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
go.sum build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
History.md build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
interface.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
levels.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
LICENSE build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
logger.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
Makefile build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
pkg.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
Readme.md build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
stack.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00

Structured logging for golang

Package log implements a simple structured logging API inspired by Logrus, designed with centralization in mind. Read more on Medium.

Handlers

  • apexlogs handler for Apex Logs
  • cli human-friendly CLI output
  • discard discards all logs
  • es  Elasticsearch handler
  • graylog Graylog handler
  • json  JSON output handler
  • kinesis AWS Kinesis handler
  • level  level filter handler
  • logfmt  logfmt plain-text formatter
  • memory in-memory handler for tests
  • multi fan-out to multiple handlers
  • papertrail Papertrail handler
  • text  human-friendly colored output
  • delta  outputs the delta between log calls and spinner

Example

Example using the Apex Logs handler.

package main

import (
	"errors"
	"time"

	"github.com/apex/log"
)

func main() {
	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")
	}
}

Build Status GoDoc