logging

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package logging provides support for logging to cloudwatch within resource providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudWatchLogGroupExists

func CloudWatchLogGroupExists(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string) (bool, error)

CloudWatchLogGroupExists checks if a log group exists

Using the client provided, it will check the CloudWatch Logs service to verify the log group

sess := session.Must(aws.NewConfig())
svc := cloudwatchlogs.New(sess)

// checks if the pineapple-pizza log group exists
ok, err := LogGroupExists(svc, "pineapple-pizza")
if err != nil {
	panic(err)
}
if ok {
	// do something
}

func CreateNewCloudWatchLogGroup

func CreateNewCloudWatchLogGroup(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string) error

CreateNewCloudWatchLogGroup creates a log group in CloudWatch Logs.

Using a passed in client to create the call to the service, it will create a log group of the specified name

sess := session.Must(aws.NewConfig())
svc := cloudwatchlogs.New(sess)

if err := CreateNewCloudWatchLogGroup(svc, "pineapple-pizza"); err != nil {
	panic("Unable to create log group", err)
}

func CreateNewLogStream

func CreateNewLogStream(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string, logStreamName string) error

CreateNewLogStream creates a log stream inside of a LogGroup

func New

func New(prefix string) *log.Logger

New sets up a logger that writes to the stderr

func NewCloudWatchLogsProvider

func NewCloudWatchLogsProvider(client cloudwatchlogsiface.CloudWatchLogsAPI, logGroupName string) (io.Writer, error)

NewCloudWatchLogsProvider creates a io.Writer that writes to a specifc log group.

Each time NewCloudWatchLogsProvider is used, a new log stream is created inside the log group. The log stream will have a unique, random identifer

sess := session.Must(aws.NewConfig())
svc := cloudwatchlogs.New(sess)

provider, err := NewCloudWatchLogsProvider(svc, "pineapple-pizza")
if err != nil {
	panic(err)
}

// set log output to the provider, all log messages will then be
// pushed through the Write func and sent to CloudWatch Logs
log.SetOutput(provider)
log.Printf("Eric loves pineapple pizza!")

func SetProviderLogOutput

func SetProviderLogOutput(w io.Writer)

SetProviderLogOutput ...

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL