# README
Cloud Watch Logs hook for Logrus 
Use this hook to send your Logrus logs to Amazon's Cloud Watch Logs.
Options
The formatter has options available to it. Please check the godoc.
Example
Look in the examples directory for more examples.
package main
import (
"io/ioutil"
"log"
"os"
"github.com/sirupsen/logrus"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/kdar/logrus-cloudwatchlogs"
)
func main() {
group := os.Getenv("AWS_CLOUDWATCHLOGS_GROUP_NAME")
stream := os.Getenv("AWS_CLOUDWATCHLOGS_STREAM_NAME")
// logs.us-east-1.amazonaws.com
// Define the session - using SharedConfigState which forces file or env creds
sess, err := session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{Region: aws.String("us-east-1")},
})
if err != nil {
panic("Not going to be able to write to cloud watch if you cant create a session")
}
// Determine if we are authorized to access AWS with the credentials provided. This does not mean you have access to the
// services required however.
_, err = sts.New(sess).GetCallerIdentity(&sts.GetCallerIdentityInput{})
if err != nil {
panic("Couldn't Validate our aws credentials")
}
hook, err := logrus_cloudwatchlogs.NewHook(group, stream, sess)
if err != nil {
log.Fatal(err)
}
l := logrus.New()
l.Hooks.Add(hook)
l.Out = ioutil.Discard
l.Formatter = logrus_cloudwatchlogs.NewProdFormatter()
l.WithFields(logrus.Fields{
"event": "testevent",
"topic": "testtopic",
"key": "testkey",
}).Fatal("Some fatal event")
}
# Packages
No description provided by the author
# Functions
AppName is a formatter option that specifies the name of the app.
Hostname is a formatter option that specifies the hostname this program is running on.
HTTPRequest is a formatter option that allows you to indicate that a certain key will contain an *http.Request.
No description provided by the author
No description provided by the author
No description provided by the author
NewProdFormatter creates a new cloudwatchlogs production formatter.
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
WriterHook is a hook that just outputs to an io.Writer.
# Interfaces
Marshaler is an interface any type can implement to change its output in our production logs.
# Type aliases
No description provided by the author