Skip to content

Commit

Permalink
Rename some field names
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTeaCat committed Jan 13, 2025
1 parent f4b1375 commit bd7aad2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions logging/batch_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ type batchLogger struct {

// BatchLoggerOptions is an options struct used by the NewBatchLogger constructor
type BatchLoggerOptions struct {
MaxBatchSize int // The maximum size of a batch in bytes
MaxLogAge time.Duration // The maximum age of a log item in a batch - once an item is older than this, the batch is passed to the callback
LogApiKey string // The API key used by the default BatchCallback used to send logs to the Firetail logging API
LogApiUrl string // The URL of the Firetail logging API endpoint to send log entries to
RedactRequestJSONPayloadValues bool // Whether or not values in the request payloads should be redacted, assuming they're JSON
RedactResponseJSONPayloadValues bool // Whether or not values in the response payloads should be redacted, assuming they're JSON
BatchCallback func([][]byte) // An optional callback to which batches will be passed; the default callback sends logs to the Firetail logging API
MaxBatchSize int // The maximum size of a batch in bytes
MaxLogAge time.Duration // The maximum age of a log item in a batch - once an item is older than this, the batch is passed to the callback
LogApiKey string // The API key used by the default BatchCallback used to send logs to the Firetail logging API
LogApiUrl string // The URL of the Firetail logging API endpoint to send log entries to
RedactJSONRequestBodies bool // Whether or not values in the request payloads should be redacted, assuming they're JSON
RedactJSONResponseBodies bool // Whether or not values in the response payloads should be redacted, assuming they're JSON
BatchCallback func([][]byte) // An optional callback to which batches will be passed; the default callback sends logs to the Firetail logging API
}

// NewBatchLogger creates a new batchLogger with the provided options
Expand All @@ -33,8 +33,8 @@ func NewBatchLogger(options BatchLoggerOptions) *batchLogger {
maxBatchSize: options.MaxBatchSize,
maxLogAge: options.MaxLogAge,
batchCallback: options.BatchCallback,
redactRequestBodies: options.RedactRequestJSONPayloadValues,
redactResponseBodies: options.RedactResponseJSONPayloadValues,
redactRequestBodies: options.RedactJSONRequestBodies,
redactResponseBodies: options.RedactJSONResponseBodies,
}

if options.BatchCallback == nil {
Expand Down
8 changes: 4 additions & 4 deletions logging/batch_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

func SetupLogger(batchChannel chan *[][]byte, maxBatchSize int, maxLogAge time.Duration, redactRequests bool, redactResponses bool) *batchLogger {
batchLogger := NewBatchLogger(BatchLoggerOptions{
MaxBatchSize: maxBatchSize,
MaxLogAge: maxLogAge,
RedactRequestJSONPayloadValues: redactRequests,
RedactResponseJSONPayloadValues: redactResponses,
MaxBatchSize: maxBatchSize,
MaxLogAge: maxLogAge,
RedactJSONRequestBodies: redactRequests,
RedactJSONResponseBodies: redactResponses,
})

// Replace the batchHandler with a custom one to throw the batches into a queue that we can receive from for testing
Expand Down
14 changes: 7 additions & 7 deletions middlewares/http/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func GetMiddleware(options *Options) (func(next http.Handler) http.Handler, erro
maxLogAge = options.MaxLogAge
}
batchLogger := logging.NewBatchLogger(logging.BatchLoggerOptions{
MaxBatchSize: maxBatchSize,
MaxLogAge: maxLogAge,
BatchCallback: options.LogBatchCallback,
LogApiKey: options.LogsApiToken,
LogApiUrl: options.LogsApiUrl,
RedactRequestJSONPayloadValues: options.RedactJSONRequestBodies,
RedactResponseJSONPayloadValues: options.RedactJSONResponseBodies,
MaxBatchSize: maxBatchSize,
MaxLogAge: maxLogAge,
BatchCallback: options.LogBatchCallback,
LogApiKey: options.LogsApiToken,
LogApiUrl: options.LogsApiUrl,
RedactJSONRequestBodies: options.RedactJSONRequestBodies,
RedactJSONResponseBodies: options.RedactJSONResponseBodies,
})

middleware := func(next http.Handler) http.Handler {
Expand Down

0 comments on commit bd7aad2

Please sign in to comment.