8000 GitHub - pikabot-org/zapcloudwatch: Cloudwatch hook for zap
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pikabot-org/zapcloudwatch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudwatch hook for zap

Example

package main

import (
	"github.com/bahadirbb/zapcloudwatch"
	"go.uber.org/zap"
)

func getLogger(name string) *zap.Logger {

	cred := credentials.NewStaticCredentials(awsAccessKey, awsSecretKey, "")
	cfg := aws.NewConfig().WithRegion(awsRegion).WithCredentials(cred)

	cloudwatchHook, err := zapcloudwatch.NewCloudwatchHook("xyz", "xyz1", false, cfg, zapcore.InfoLevel).GetHook()
	if err != nil {
		panic(err)
	}

	config := zap.NewDevelopmentConfig()
	config.Encoding = "json"
	logger, _ := config.Build()
	logger = logger.WithOptions(zap.Hooks(cloudwatch
5EB0
Hook)).Named(name)
	return logger
}

func main() {
	logger, _ := getLogger("test")

	logger.Debug("don't need to send a message")
	logger.Error("an error happened!")
}

Install

$ go get -u github.com/bahadirbb/zapcloudwatch

This is a mixin project from these 2 repositories. Warning as a zaphook this hook doesn't log fields. If you need complete logging with fields don't use this hook. You need to implement zap.Core

https://github.com/bluele/zapslack

https://github.com/kdar/logrus-cloudwatchlogs

Author

Bahadir Bozdag

About

Cloudwatch hook for zap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
0