Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate non-code scaffolding #1

Merged
merged 4 commits into from Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
@@ -0,0 +1,12 @@
language: go
go:
- 1.6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we also test against 1.5 for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

- tip
cache:
directories:
- vendor
install:
- make dependencies
script:
- make coveralls
- make lint
19 changes: 19 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,19 @@
Copyright (c) 2016 Uber Technologies, Inc.

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.
59 changes: 59 additions & 0 deletions Makefile
@@ -0,0 +1,59 @@
# Copyright (c) 2016 Uber Technologies, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we haven't put the license in our Makefile for tchannel-go or ringpop-go. Not sure whether it's needed or not, do we need to add it to them in our other repos @jwolski?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll remove it.


# 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.

BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
PACKAGES ?= $(shell glide novendor)

.PHONY: all
all: lint test

.PHONY: dependencies
dependencies:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest renaming to install - that seems to be more common

glide --version || go get -u -f github.com/Masterminds/glide
glide install
go install ./vendor/github.com/golang/lint/golint
go install ./vendor/github.com/axw/gocov/gocov
go install ./vendor/github.com/mattn/goveralls

.PHONY: lint
lint:
rm -rf lint.log
@echo "Checking formatting..."
gofmt -d -s *.go benchmarks 2>&1 | tee lint.log
@echo "Checking vet..."
go tool vet *.go 2>&1 | tee -a lint.log
go tool vet benchmarks 2>&1 | tee -a lint.log
@echo "Checking lint..."
golint . 2>&1 | tee -a lint.log
golint benchmarks 2>&1 | tee -a lint.log
@[ ! -s lint.log ]

.PHONY: test
test:
go test -race $(PACKAGES)

.PHONY: coveralls
coveralls:
goveralls -service=travis-ci $(PACKAGES)

.PHONY: bench
BENCH ?= .
bench:
go test -bench=$(BENCH) $(BENCH_FLAGS) ./benchmarks
73 changes: 73 additions & 0 deletions README.md
@@ -0,0 +1,73 @@
# :zap: zap [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]

Fast, structured, leveled logging in Go.

## Structure

Zap takes an opinionated stance on logging and doesn't provide any
`printf`-style helpers. Rather than `logger.Printf("Error %v writing logs to
%v, lost %v messages.", err, f, m)`, flog encourages the more structured

```
Logger.
WithError(err).
With("msgCount", m).
With("fileName", f).
Info("Error writing logs.")
```

This a bit more verbose, but it enables powerful ad-hoc analysis, flexible
dashboarding, and accurate message bucketing. In short, it helps you get the
most out of tools like ELK, Splunk, and Sentry. All log messages are
JSON-serialized.

## Performance

For applications that log in the hot path, reflection-based serialization and
string formatting are prohibitively expensive — they're CPU-intensive and
make many small allocations. Put differently, using `encoding/json` to log tons
of `interface{}`s makes your application slow.

Zap's API offers a variety of type-safe ways to annotate a logger's context
without incurring tons of overhead. It also offers a suite of conditional
annotations, so collecting rich debugging context doesn't impact normal
operations.

As measured by its own benchmarking suite, not only is zap more performant
than comparable structured logging libraries — it's also faster than the
standard library. Like all benchmarks, take these with a grain of salt.

Add 5 fields to the logging context, one at a time:

| Library | Time | Bytes Allocated | Objects Allocated |
| :--- | :---: | :---: | ---: |
| zap | 3340 ns/op | 5713 B/op | 16 allocs/op |
| logrus | 66776 ns/op | 52646 B/op | 254 allocs/op |

Add 5 fields to the logging context as a single map:

| Library | Time | Bytes Allocated | Objects Allocated |
| :--- | :---: | :---: | ---: |
| zap | 1615 ns/op | 1504 B/op | 6 allocs/op |
| logrus | 36592 ns/op | 21409 B/op | 209 allocs/op |

Log static strings, without any context or `printf`-style formatting:

| Library | Time | Bytes Allocated | Objects Allocated |
| :--- | :---: | :---: | ---: |
| zap | 328 ns/op | 32 B/op | 1 allocs/op |
| standard library | 840 ns/op | 592 B/op | 2 allocs/op |

## Development Status: Alpha

Breaking changes are certain.

<hr>
Released under the [MIT License](LICENSE.txt).

[doc-img]: https://godoc.org/github.com/uber-common/zap?status.svg
[doc]: https://godoc.org/github.com/uber-common/zap
[ci-img]: https://travis-ci.org/uber-common/zap.svg?branch=master
[ci]: https://travis-ci.org/uber-common/zap
[cov-img]: https://coveralls.io/repos/github/uber-common/zap/badge.svg?branch=master
[cov]: https://coveralls.io/github/uber-common/zap?branch=master
51 changes: 51 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions glide.yaml
@@ -0,0 +1,20 @@
package: github.com/akshayjshah/flog
import:
- package: github.com/stretchr/testify
subpackages:
- assert
- require
- package: github.com/golang/lint
subpackages:
- golint
- package: github.com/mattn/goveralls
- package: github.com/Sirupsen/logrus
- package: github.com/axw/gocov
subpackages:
- gocov
- package: github.com/golang/glog
- package: github.com/go-kit/kit
subpackages:
- log
- package: gopkg.in/logfmt.v0
- package: gopkg.in/stack.v1