logging

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

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