You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/tyuio9/logrus-cloudwatchlogs-async

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tyuio9/logrus-cloudwatchlogs-async

v0.0.0-20201014154343-0156fbf6990a
Source
Go
Version published
Created
Source

Asynchronous CloudWatch Logs hook for Logrus

Send Logrus logs to Amazon's CloudWatch Logs service.

Inspired by logrus-cloudwatchlogs, but it sends logs asynchronously, therefore it doesn't impair application performance. It can also handle the host temporarily going offline.

Example

package main

import (
	"os"

	"github.com/sirupsen/logrus"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/szemate/logrus-cloudwatchlogs-async"
)

func main() {
	key := os.Getenv("AWS_ACCESS_KEY")
	secret := os.Getenv("AWS_SECRET_KEY")
	group := os.Getenv("AWS_CLOUDWATCHLOGS_GROUP_NAME")
	stream := os.Getenv("AWS_CLOUDWATCHLOGS_STREAM_NAME")

	cred := credentials.NewStaticCredentials(key, secret, "")
	cfg := aws.NewConfig().WithRegion("us-east-1").WithCredentials(cred)

	logger := logrus.New()

	hook, err := logrus_cloudwatchlogs_async.NewHook(group, stream, cfg)
	if err != nil {
		logger.Fatal(err)
	}
	logger.Hooks.Add(hook)

	logger.Fatal("Some fatal event")
}

FAQs

Package last updated on 14 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts