This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #447 from jfrazelle/update-logrus
Update logrus to 0.6.6
- Loading branch information
Showing
24 changed files
with
746 additions
and
54 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package logrus | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEntryPanicln(t *testing.T) { | ||
errBoom := fmt.Errorf("boom time") | ||
|
||
defer func() { | ||
p := recover() | ||
assert.NotNil(t, p) | ||
|
||
switch pVal := p.(type) { | ||
case *Entry: | ||
assert.Equal(t, "kaboom", pVal.Message) | ||
assert.Equal(t, errBoom, pVal.Data["err"]) | ||
default: | ||
t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) | ||
} | ||
}() | ||
|
||
logger := New() | ||
logger.Out = &bytes.Buffer{} | ||
entry := NewEntry(logger) | ||
entry.WithField("err", errBoom).Panicln("kaboom") | ||
} | ||
|
||
func TestEntryPanicf(t *testing.T) { | ||
errBoom := fmt.Errorf("boom again") | ||
|
||
defer func() { | ||
p := recover() | ||
assert.NotNil(t, p) | ||
|
||
switch pVal := p.(type) { | ||
case *Entry: | ||
assert.Equal(t, "kaboom true", pVal.Message) | ||
assert.Equal(t, errBoom, pVal.Data["err"]) | ||
default: | ||
t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) | ||
} | ||
}() | ||
|
||
logger := New() | ||
logger.Out = &bytes.Buffer{} | ||
entry := NewEntry(logger) | ||
entry.WithField("err", errBoom).Panicf("kaboom %v", true) | ||
} |
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
vendor/src/github.com/Sirupsen/logrus/hooks/sentry/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Sentry Hook for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:" /> | ||
|
||
[Sentry](https://getsentry.com) provides both self-hosted and hosted | ||
solutions for exception tracking. | ||
Both client and server are | ||
[open source](https://github.com/getsentry/sentry). | ||
|
||
## Usage | ||
|
||
Every sentry application defined on the server gets a different | ||
[DSN](https://www.getsentry.com/docs/). In the example below replace | ||
`YOUR_DSN` with the one created for your application. | ||
|
||
```go | ||
import ( | ||
"github.com/Sirupsen/logrus" | ||
"github.com/Sirupsen/logrus/hooks/sentry" | ||
) | ||
|
||
func main() { | ||
log := logrus.New() | ||
hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{ | ||
logrus.PanicLevel, | ||
logrus.FatalLevel, | ||
logrus.ErrorLevel, | ||
}) | ||
|
||
if err == nil { | ||
log.Hooks.Add(hook) | ||
} | ||
} | ||
``` | ||
|
||
## Special fields | ||
|
||
Some logrus fields have a special meaning in this hook, | ||
these are server_name and logger. | ||
When logs are sent to sentry these fields are treated differently. | ||
- server_name (also known as hostname) is the name of the server which | ||
is logging the event (hostname.example.com) | ||
- logger is the part of the application which is logging the event. | ||
In go this usually means setting it to the name of the package. | ||
|
||
## Timeout | ||
|
||
`Timeout` is the time the sentry hook will wait for a response | ||
from the sentry server. | ||
|
||
If this time elapses with no response from | ||
the server an error will be returned. | ||
|
||
If `Timeout` is set to 0 the SentryHook will not wait for a reply | ||
and will assume a correct delivery. | ||
|
||
The SentryHook has a default timeout of `100 milliseconds` when created | ||
with a call to `NewSentryHook`. This can be changed by assigning a value to the `Timeout` field: | ||
|
||
```go | ||
hook, _ := logrus_sentry.NewSentryHook(...) | ||
hook.Timeout = 20*time.Second | ||
``` |
Oops, something went wrong.