From bd7aad26d79522d9eaa27164fea3866f7caabc1d Mon Sep 17 00:00:00 2001 From: theteacat Date: Mon, 13 Jan 2025 14:48:45 +0000 Subject: [PATCH] Rename some field names --- logging/batch_logger.go | 18 +++++++++--------- logging/batch_logger_test.go | 8 ++++---- middlewares/http/middleware.go | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/logging/batch_logger.go b/logging/batch_logger.go index 39d9139..92d7288 100644 --- a/logging/batch_logger.go +++ b/logging/batch_logger.go @@ -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 @@ -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 { diff --git a/logging/batch_logger_test.go b/logging/batch_logger_test.go index dbf31c7..c9824b6 100644 --- a/logging/batch_logger_test.go +++ b/logging/batch_logger_test.go @@ -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 diff --git a/middlewares/http/middleware.go b/middlewares/http/middleware.go index 90733fd..c2cfbf2 100644 --- a/middlewares/http/middleware.go +++ b/middlewares/http/middleware.go @@ -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 {