pax_global_header 0000666 0000000 0000000 00000000064 13316445770 0014524 g ustar 00root root 0000000 0000000 52 comment=941dea75d3ebfbdd905a5d8b7b232965c5e5c684
log-1.1.0/ 0000775 0000000 0000000 00000000000 13316445770 0012304 5 ustar 00root root 0000000 0000000 log-1.1.0/LICENSE 0000664 0000000 0000000 00000002112 13316445770 0013305 0 ustar 00root root 0000000 0000000 (The MIT License)
Copyright (c) 2015 TJ Holowaychuk tj@tjholowaychuk.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
log-1.1.0/Makefile 0000664 0000000 0000000 00000000043 13316445770 0013741 0 ustar 00root root 0000000 0000000
include github.com/tj/make/golang
log-1.1.0/Readme.md 0000664 0000000 0000000 00000002361 13316445770 0014025 0 ustar 00root root 0000000 0000000

Package log implements a simple structured logging API inspired by Logrus, designed with centralization in mind. Read more on [Medium](https://medium.com/@tjholowaychuk/apex-log-e8d9627f4a9a#.rav8yhkud).
## Handlers
- __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
---
[](https://semaphoreci.com/tj/log)
[](https://godoc.org/github.com/apex/log)


log-1.1.0/_examples/ 0000775 0000000 0000000 00000000000 13316445770 0014261 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/cli/ 0000775 0000000 0000000 00000000000 13316445770 0015030 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/cli/cli.go 0000664 0000000 0000000 00000001343 13316445770 0016127 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
)
func main() {
log.SetHandler(cli.Default)
log.SetLevel(log.DebugLevel)
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})
go func() {
for range time.Tick(time.Second) {
ctx.Debug("doing stuff")
}
}()
go func() {
for range time.Tick(100 * time.Millisecond) {
ctx.Info("uploading")
ctx.Info("upload complete")
}
}()
go func() {
for range time.Tick(time.Second) {
ctx.Warn("upload slow")
}
}()
go func() {
for range time.Tick(2 * time.Second) {
err := errors.New("boom")
ctx.WithError(err).Error("upload failed")
}
}()
select {}
}
log-1.1.0/_examples/default/ 0000775 0000000 0000000 00000000000 13316445770 0015705 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/default/default.go 0000664 0000000 0000000 00000000662 13316445770 0017664 0 ustar 00root root 0000000 0000000 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")
}
}
log-1.1.0/_examples/delta/ 0000775 0000000 0000000 00000000000 13316445770 0015352 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/delta/delta.go 0000664 0000000 0000000 00000001347 13316445770 0016777 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/delta"
)
func main() {
log.SetHandler(delta.Default)
log.SetLevel(log.DebugLevel)
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})
go func() {
for range time.Tick(time.Second) {
ctx.Debug("doing stuff")
}
}()
go func() {
for range time.Tick(100 * time.Millisecond) {
ctx.Info("uploading")
ctx.Info("upload complete")
}
}()
go func() {
for range time.Tick(time.Second) {
ctx.Warn("upload slow")
}
}()
go func() {
for range time.Tick(2 * time.Second) {
err := errors.New("boom")
ctx.WithError(err).Error("upload failed")
}
}()
select {}
}
log-1.1.0/_examples/es/ 0000775 0000000 0000000 00000000000 13316445770 0014670 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/es/es.go 0000664 0000000 0000000 00000001721 13316445770 0015627 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"net/http"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/es"
"github.com/apex/log/handlers/multi"
"github.com/apex/log/handlers/text"
"github.com/tj/go-elastic"
)
func main() {
esClient := elastic.New("http://192.168.99.101:9200")
esClient.HTTPClient = &http.Client{
Timeout: 5 * time.Second,
}
e := es.New(&es.Config{
Client: esClient,
BufferSize: 100,
})
t := text.New(os.Stderr)
log.SetHandler(multi.New(e, t))
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})
go func() {
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")
}
}()
go func() {
for range time.Tick(time.Millisecond * 25) {
ctx.Info("upload")
}
}()
select {}
}
log-1.1.0/_examples/json/ 0000775 0000000 0000000 00000000000 13316445770 0015232 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/json/json.go 0000664 0000000 0000000 00000000724 13316445770 0016535 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/json"
)
func main() {
log.SetHandler(json.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")
}
}
log-1.1.0/_examples/kinesis/ 0000775 0000000 0000000 00000000000 13316445770 0015726 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/kinesis/kinesis.go 0000664 0000000 0000000 00000000742 13316445770 0017725 0 ustar 00root root 0000000 0000000 package main
import (
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/kinesis"
"github.com/apex/log/handlers/multi"
"github.com/apex/log/handlers/text"
)
func main() {
log.SetHandler(multi.New(
text.New(os.Stderr),
kinesis.New("logs"),
))
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})
for range time.Tick(time.Millisecond * 100) {
ctx.Info("upload")
ctx.Info("upload complete")
}
}
log-1.1.0/_examples/logfmt/ 0000775 0000000 0000000 00000000000 13316445770 0015551 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/logfmt/logfmt.go 0000664 0000000 0000000 00000000730 13316445770 0017370 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/logfmt"
)
func main() {
log.SetHandler(logfmt.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")
}
}
log-1.1.0/_examples/multi/ 0000775 0000000 0000000 00000000000 13316445770 0015413 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/multi/multi.go 0000664 0000000 0000000 00000001107 13316445770 0017073 0 ustar 00root root 0000000 0000000 package main
import (
"errors"
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/json"
"github.com/apex/log/handlers/multi"
"github.com/apex/log/handlers/text"
)
func main() {
log.SetHandler(multi.New(
text.New(os.Stderr),
json.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")
}
}
log-1.1.0/_examples/stack/ 0000775 0000000 0000000 00000000000 13316445770 0015366 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/stack/stack.go 0000664 0000000 0000000 00000001175 13316445770 0017026 0 ustar 00root root 0000000 0000000 package main
import (
"os"
"github.com/pkg/errors"
"github.com/apex/log"
"github.com/apex/log/handlers/logfmt"
)
func main() {
log.SetHandler(logfmt.New(os.Stderr))
filename := "something.png"
body := []byte("whatever")
ctx := log.WithField("filename", filename)
err := upload(filename, body)
if err != nil {
ctx.WithError(err).Error("upload failed")
}
}
// Faux upload.
func upload(name string, b []byte) error {
err := put("/images/"+name, b)
if err != nil {
return errors.Wrap(err, "uploading to s3")
}
return nil
}
// Faux PUT.
func put(key string, b []byte) error {
return errors.New("unauthorized")
}
log-1.1.0/_examples/text/ 0000775 0000000 0000000 00000000000 13316445770 0015245 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/text/text.go 0000664 0000000 0000000 00000001003 13316445770 0016552 0 ustar 00root root 0000000 0000000 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")
}
}
log-1.1.0/_examples/trace/ 0000775 0000000 0000000 00000000000 13316445770 0015357 5 ustar 00root root 0000000 0000000 log-1.1.0/_examples/trace/trace.go 0000664 0000000 0000000 00000000677 13316445770 0017016 0 ustar 00root root 0000000 0000000 package main
import (
"os"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/text"
)
func work(ctx log.Interface) (err error) {
path := "Readme.md"
defer ctx.WithField("path", path).Trace("opening").Stop(&err)
_, err = os.Open(path)
return
}
func main() {
log.SetHandler(text.New(os.Stderr))
ctx := log.WithFields(log.Fields{
"app": "myapp",
"env": "prod",
})
for range time.Tick(time.Second) {
_ = work(ctx)
}
}
log-1.1.0/assets/ 0000775 0000000 0000000 00000000000 13316445770 0013606 5 ustar 00root root 0000000 0000000 log-1.1.0/assets/title.png 0000664 0000000 0000000 00000105023 13316445770 0015436 0 ustar 00root root 0000000 0000000 PNG
IHDR v OOa sRGB @ IDATx U7`A1,"Y*,D\aDaA\qAYGAEQpEY 2̌ʀ|]@"0d~jo{owt