import (
"github.com/Sirupsen/logrus"
"github.com/beaubrewer/logrus_firehose"
)
func main() {
hook, err := logrus_firehose.New("my_stream", Config{
AccessKey: "ABC", // AWS accessKeyId
SecretKey: "XYZ", // AWS secretAccessKey
Region: "us-west-2",
})
// set custom fire level
hook.SetLevels([]logrus.Level{
logrus.PanicLevel,
logrus.ErrorLevel,
})
// ignore field
hook.AddIgnore("context")
// add custome filter
hook.AddFilter("error", logrus_firehose.FilterError)
// send log with logrus
logger := logrus.New()
logger.Hooks.Add(hook)
logger.WithFields(f).Error("my_message") // send log data to firehose as JSON
}
Some logrus fields have a special meaning in this hook.
message |
if message is not set, entry.Message is added to log data in "message" field. |
stream_name |
stream_name isthe stream name for Firehose. If not set, defaultStreamName is used as stream name. |
logrus_firehose | |
==== |
import (
"github.com/Sirupsen/logrus"
"github.com/beaubrewer/logrus_firehose"
)
func main() {
hook, err := logrus_firehose.New("my_stream", Config{
AccessKey: "ABC", // AWS accessKeyId
SecretKey: "XYZ", // AWS secretAccessKey
Region: "us-west-2",
})
// set custom fire level
hook.SetLevels([]logrus.Level{
logrus.PanicLevel,
logrus.ErrorLevel,
})
// ignore field
hook.AddIgnore("context")
// add custome filter
hook.AddFilter("error", logrus_firehose.FilterError)
// send log with logrus
logger := logrus.New()
logger.Hooks.Add(hook)
logger.WithFields(f).Error("my_message") // send log data to firehose as JSON
}
Some logrus fields have a special meaning in this hook.
message |
if message is not set, entry.Message is added to log data in "message" field. |
stream_name |
stream_name isthe stream name for Firehose. If not set, defaultStreamName is used as stream name. |