Skip to content

Commit d76e814

Browse files
committed
v0.0.1 - initial release
0 parents  commit d76e814

13 files changed

+660
-0
lines changed

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.dll
4+
*.so
5+
*.dylib
6+
7+
# Test binary, build with `go test -c`
8+
*.test
9+
10+
# Output of the go coverage tool, specifically when used with LiteIDE
11+
*.out
12+
13+
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
14+
.glide/
15+
16+
.env
17+
vendor
18+
bin/publisher
19+
bin/consumer
20+
!.gitkeep

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dist: trusty
2+
language: go
3+
go:
4+
- 1.9
5+
before_install: make init
6+
install: make init
7+
script: make ci
8+
notifications:
9+
email:
10+
on_success: never
11+
on_failure: always

CODE_OF_CONDUCT.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
26+
* Trolling, insulting/derogatory comments, and personal or political attacks
27+
* Public or private harassment
28+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
29+
* Other conduct which could reasonably be considered inappropriate in a professional setting
30+
31+
## Our Responsibilities
32+
33+
Project maintainers are responsible for clarifying the standards of acceptable
34+
behavior and are expected to take appropriate and fair corrective action in
35+
response to any instances of unacceptable behavior.
36+
37+
Project maintainers have the right and responsibility to remove, edit, or
38+
reject comments, commits, code, wiki edits, issues, and other contributions
39+
that are not aligned to this Code of Conduct, or to ban temporarily or
40+
permanently any contributor for other behaviors that they deem inappropriate,
41+
threatening, offensive, or harmful.
42+
43+
## Scope
44+
45+
This Code of Conduct applies both within project spaces and in public spaces
46+
when an individual is representing the project or its community. Examples of
47+
representing a project or community include using an official project e-mail
48+
address, posting via an official social media account, or acting as an appointed
49+
representative at an online or offline event. Representation of a project may be
50+
further defined and clarified by project maintainers.
51+
52+
## Enforcement
53+
54+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
55+
reported by contacting the project team at [[email protected]](mailto:[email protected]). All
56+
complaints will be reviewed and investigated and will result in a response that
57+
is deemed necessary and appropriate to the circumstances. The project team is
58+
obligated to maintain confidentiality with regard to the reporter of an incident.
59+
Further details of specific enforcement policies may be posted separately.
60+
61+
Project maintainers who do not follow or enforce the Code of Conduct in good
62+
faith may face temporary or permanent repercussions as determined by other
63+
members of the project's leadership.
64+
65+
## Attribution
66+
67+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
68+
available at [http://contributor-covenant.org/version/1/4][version]
69+
70+
[homepage]: http://contributor-covenant.org
71+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
3+
First of all, thank you for wanting to contibute to a Hyperdriven project! :raised_hands:
4+
5+
We welcome and encourage contibutions (no matter how big or small) from **everyone**. By participating, you agree to abide by [our code of conduct](CODE_OF_CONDUCT.md).
6+
7+
## Ways You Can Contribute
8+
9+
- [Submit a Pull Request](#pull-requests) :octocat: :shipit:
10+
- [Edit the Wiki](https://github.com/macandmia/logbeat/wiki) :pencil:
11+
- [Report a Bug](https://github.com/macandmia/logbeat/issues/new?labels=bug) :beetle:
12+
- [Suggest a Feature](https://github.com/macandmia/logbeat/issues/new?labels=enhancement) :bulb:
13+
- [Tell us](mailto:[email protected]) about a project you used this in. :mailbox_with_mail:
14+
- Write about us on your blog or social media! :mega:
15+
16+
## Pull Requests
17+
18+
1. [Fork the repo](https://github.com/macandmia/logbeat#fork-destination-box)
19+
20+
2. Clone your fork:
21+
22+
git clone [email protected]:your-username/logbeat.git
23+
24+
3. Set up your machine:
25+
26+
./scripts/setup
27+
28+
4. Install dependencies:
29+
30+
./scripts/install
31+
32+
5. Make sure the tests pass:
33+
34+
./scripts/test
35+
36+
6. Make your change. Add tests, and ensure the tests pass:
37+
38+
./scripts/test
39+
40+
7. Commit your changes (squash your commits, if needed), push your fork, and [submit a pull request](https://github.com/macandmia/logbeat/compare/)
41+
42+
At this point you're waiting on us. We will try to review your submissions within three days -- typically sooner than that. We may suggest some changes, improvements or alternative approaches -- please be open to feedback, as we have to consider how your change fits into the over all design and vision of the project.
43+
44+
Some things that will increase the chance that your pull request is accepted:
45+
46+
- Break unrelated changes up into multiple pull requests -- our change log is generated automatically from merged pull requests.
47+
- Add your changes to one of the existing files in our package, unless you are introducing an entirely new concept (in which case, you can create a new file).
48+
- Write tests. We use [testify](https://github.com/stretchr/testify) for our unit tests.
49+
- Follow the Golang [style guide](https://github.com/golang/go/wiki/CodeReviewComments).
50+
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
51+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 [email protected]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
GLIDE := $(shell command -v glide 2> /dev/null)
2+
GOVERALLS := $(shell command -v goveralls 2> /dev/null)
3+
GOLINT := $(shell command -v golint 2> /dev/null)
4+
GEM := $(shell command -v golint 2> /dev/null)
5+
GCG := $(shell command -v github_changelog_generator 2> /dev/null)
6+
7+
.PHONY: init deps test ci release
8+
9+
# setup project
10+
init:
11+
ifndef GLIDE
12+
go get -u github.com/Masterminds/glide
13+
else
14+
@echo "Already Installed: glide. Skipping."
15+
endif
16+
ifndef GOVERALLS
17+
go get -u github.com/mattn/goveralls
18+
else
19+
@echo "Already Installed: goveralls. Skipping."
20+
endif
21+
ifndef GOLINT
22+
go get -u github.com/golang/lint/golint
23+
else
24+
@echo "Already Installed: golint. Skipping."
25+
endif
26+
ifdef GEM
27+
ifndef GCG
28+
gem install github_changelog_generator --no-ri --no-rdoc
29+
else
30+
@echo "Already Installed: github_changelog_generator. Skipping."
31+
endif
32+
endif
33+
glide install
34+
35+
# install dependencies
36+
deps:
37+
glide up
38+
39+
# test package
40+
test:
41+
go test $(glide nv)
42+
43+
ci: test
44+
goveralls -service=travis-ci
45+
46+
# release package
47+
release:
48+
rm -f .git/RELEASE_EDITMSG
49+
touch .git/RELEASE_EDITMSG
50+
echo "${1}\n\n${@}" >> .git/RELEASE_EDITMSG
51+
git tag -s ${1} -F .git/RELEASE_EDITMSG
52+
git push --tags
53+
github_changelog_generator --issue-line-labels="ALL" --release-url="https://github.com/macandmia/logbeat/releases/tag/%s"
54+
git commit CHANGELOG.md -m "updates changelog for ${1}"
55+
git push origin master
56+
hub release create -f .git/RELEASE_EDITMSG ${1}

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# logbeat [![Build Status](https://travis-ci.org/macandmia/logbeat.svg?branch=master)](https://travis-ci.org/macandmia/logbeat) [![GoDoc](https://godoc.org/github.com/macandmia/logbeat?status.svg)](https://godoc.org/github.com/macandmia/logbeat) [![Go Report Card](https://goreportcard.com/badge/github.com/macandmia/logbeat)](https://goreportcard.com/report/github.com/macandmia/logbeat) [![Coverage Status](https://coveralls.io/repos/github/macandmia/logbeat/badge.svg)](https://coveralls.io/github/macandmia/logbeat) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/macandmia/logbeat/blob/master/LICENSE)
2+
3+
`logbeat` is a [Logrus](https://github.com/sirupsen/logrus) Hook to report errors to [Opbeat](https://opbeat.com/).
4+
5+
---
6+
7+
## Install
8+
9+
go get https://github.com/macandmia/logbeat
10+
11+
## Import
12+
13+
import "github.com/macandmia/logbeat"
14+
15+
## Usage
16+
17+
```go
18+
package main
19+
20+
import (
21+
"os"
22+
23+
log "github.com/sirupsen/logrus"
24+
logbeat "github.com/macandmia/logbeat"
25+
)
26+
27+
func init() {
28+
orgId := os.Getenv("OPBEAT_ORGANIZATION_ID")
29+
appId := os.Getenv("OPBEAT_APP_ID")
30+
token := os.Getenv("OPBEAT_SECRET_TOKEN")
31+
log.AddHook(logbeat.NewOpbeatHook(orgId, appId, token))
32+
}
33+
34+
func main() {
35+
log.WithField("notify", "opbeat").Error("This error will be sent to Opbeat")
36+
}
37+
```
38+
39+
## Contributing
40+
41+
Refer to our [Contributor's Guide](CONTRIBUTING.md) to learn how you can participate in this project.
42+
43+
## More Info
44+
45+
- [GoDoc](https://godoc.org/github.com/macandmia/logbeat)
46+
- [Wiki](https://github.com/macandmia/logbeat/wiki)

glide.lock

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package: github.com/macandmia/logbeat
2+
import:
3+
- package: github.com/sirupsen/logrus
4+
version: ~1.0.0
5+
testImport:
6+
- package: github.com/jarcoal/httpmock
7+
version: v1
8+
- package: github.com/stretchr/testify
9+
version: ~1.1.4
10+
subpackages:
11+
- suite

logbeat.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package logbeat
2+
3+
import (
4+
"github.com/sirupsen/logrus"
5+
)
6+
7+
const LogbeatVersion string = "0.0.1"
8+
9+
// OpbeatHook delivers logs to the Opbeat service.
10+
type LogbeatHook struct {
11+
AppId string
12+
Opbeat *OpbeatClient
13+
OrgId string
14+
SecretToken string
15+
}
16+
17+
// NewOpbeatHook creates a new LogbeatHook that reports
18+
// Errors, Fatal Errors, and Panics from Logrus to Opbeat.
19+
func NewOpbeatHook(org, app, token string) *LogbeatHook {
20+
return &LogbeatHook{
21+
OrgId: org,
22+
AppId: app,
23+
SecretToken: token,
24+
Opbeat: NewOpbeatClient(org, app, token),
25+
}
26+
}
27+
28+
// Fire is called by Logrus when an Error occurs. The given Logrus Entry
29+
// will be sent to Opbeat's Error Intake API.
30+
func (hook *LogbeatHook) Fire(entry *logrus.Entry) error {
31+
_, err := hook.Opbeat.Notify(entry)
32+
return err
33+
}
34+
35+
// Levels tells Logrus which types of logging events we
36+
// are interseted in (e.g. Errors, Fatal Errors, Panics).
37+
func (hook *LogbeatHook) Levels() []logrus.Level {
38+
return []logrus.Level{
39+
logrus.PanicLevel,
40+
logrus.FatalLevel,
41+
logrus.ErrorLevel,
42+
}
43+
}

0 commit comments

Comments
 (0)