Documentation
¶
Overview ¶
Package cowl implements an io.Writer that sends logs in batches to Cloudwatch Logs. Copyright © 2017 Reed O'Brien <reed+oss@reedobrien.com>. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Index ¶
Constants ¶
const ( // DefaultFlushPeriod is the default period between flushes if the max size // threshold isn't met. DefaultFlushPeriod = 10 * time.Second // DefaultFlushSize is the maximum size the buffer can reach before // flushing if the flush period duration hasn't passed. DefaultFlushSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientAPI ¶
type ClientAPI interface { PutLogEvents(*cloudwatchlogs.PutLogEventsInput) (*cloudwatchlogs.PutLogEventsOutput, error) CreateLogStream(*cloudwatchlogs.CreateLogStreamInput) (*cloudwatchlogs.CreateLogStreamOutput, error) DescribeLogStreams(*cloudwatchlogs.DescribeLogStreamsInput) (*cloudwatchlogs.DescribeLogStreamsOutput, error) }
ClientAPI is an interface limited to the methods we want to use. https://github.com/aws/aws-sdk-go/blob/master/service/cloudwatchlogs/cloudwatchlogsiface/interface.go
type Writer ¶
type Writer struct { API ClientAPI FlushPeriod time.Duration FlushSize int // contains filtered or unexported fields }
Writer implements io.Writer and sends the incoming stream to CloudWatch Logs in batches.
func MustNewWriter ¶
MustNewWriter returns a new Writer for use or panics.
func MustNewWriterWithContext ¶
func MustNewWriterWithContext(ctx context.Context, api ClientAPI, group, stream string, options ...func(*Writer)) *Writer
MustNewWriterWithContext returns a Writer using the provided context.
func (*Writer) Close ¶
func (w *Writer) Close()
Close closes the channel that accepts events. Signaling it is time to flush and exit.