Documentation
¶
Index ¶
- func ApplyBodyRedaction(body string, plan *RedactionPlan) string
- func ContainsAlwaysRedactedName(body string) bool
- func SerializeHeaders(headers http.Header, plan *RedactionPlan) string
- type Client
- func (c *Client) Enqueue(entry LogEntry, onSent OnSent, onFailed OnFailed) (bool, error)
- func (c *Client) EnqueueMany(entries []LogEntry, onSent OnSent, onFailed OnFailed) (int, error)
- func (c *Client) Logger() Logger
- func (c *Client) Middleware(opts RequestLoggingOptions) func(http.Handler) http.Handler
- func (c *Client) Shutdown(ctx context.Context) error
- type EnricherFunc
- type LogEntry
- type LogError
- type LogFailureReason
- type LogLevel
- type LogSourceType
- type Logger
- type OnFailed
- type OnSent
- type Options
- type RedactionPlan
- type RequestLoggingOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyBodyRedaction ¶
func ApplyBodyRedaction(body string, plan *RedactionPlan) string
ApplyBodyRedaction processes a request/response body according to the redaction plan. If plan.RedactAll, every JSON value is redacted; otherwise only fields the plan names (plus the built-in floor) are redacted. A body that mentions nothing sensitive is returned unprocessed.
func ContainsAlwaysRedactedName ¶
ContainsAlwaysRedactedName reports whether a raw body mentions any always-redacted name, as a whole name.
func SerializeHeaders ¶
func SerializeHeaders(headers http.Header, plan *RedactionPlan) string
SerializeHeaders converts an http.Header into single-line JSON, redacting values whose name matches the plan. Multi-value headers are joined with ", ".
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client bundles a buffered, batched log shipper with an HTTP request-logging middleware factory.
func New ¶
New creates a Pinqloq client: a buffered, batched log shipper plus an HTTP middleware factory.
func (*Client) EnqueueMany ¶ added in v1.1.0
EnqueueMany is a shortcut for Logger().EnqueueMany.
func (*Client) Logger ¶
Logger sends structured application events; buffered and delivered in the background.
func (*Client) Middleware ¶
Middleware returns standard net/http middleware that captures every HTTP request, produces one API log, and enqueues it via the client's Logger. Compatible with any router built on net/http.Handler (chi, gorilla/mux, ServeMux, ...).
type EnricherFunc ¶
EnricherFunc computes a metadata/detail value from the request and the completed response.
type LogEntry ¶
type LogEntry struct {
LogLevel LogLevel
Event string
Date time.Time
AppVersionName string
DeviceIdentifier string
LogSourceType LogSourceType
CollectionName string
CorrelationID string
Path string
Metadata map[string]string
Detail map[string]string
}
LogEntry is a single log record. The producer creates it and places it on the queue.
type LogError ¶
type LogError struct {
Reason LogFailureReason
StatusCode int
Message string
Cause error
}
LogError carries the reason a log could not be sent; passed to an OnFailed callback.
type LogFailureReason ¶
type LogFailureReason string
LogFailureReason explains why a log could not be sent.
const ( LogFailureReasonForbidden LogFailureReason = "Forbidden" LogFailureReasonQueueFull LogFailureReason = "QueueFull" LogFailureReasonHTTPError LogFailureReason = "HttpError" LogFailureReasonTimeout LogFailureReason = "Timeout" LogFailureReasonNetwork LogFailureReason = "Network" )
type LogSourceType ¶
type LogSourceType int
LogSourceType matches the server-side ClientLogSourceType one to one.
const ( LogSourceTypeDevice LogSourceType = 1 LogSourceTypeBackend LogSourceType = 2 )
type Logger ¶
type Logger interface {
Enqueue(entry LogEntry, onSent OnSent, onFailed OnFailed) (bool, error)
EnqueueMany(entries []LogEntry, onSent OnSent, onFailed OnFailed) (int, error)
}
Logger is the main interface the Pinqloq SDK uses to send logs.
type OnSent ¶
type OnSent func(entry LogEntry)
OnSent is called when a log has been successfully delivered.
type Options ¶
type Options struct {
SecretKey string
APILogsCollectionName string
BulkPath string
BatchSize int
FlushInterval time.Duration
QueueCapacity int
HTTPTimeout time.Duration
AppVersionName string
DeviceIdentifier string
}
Options configures a Client.
type RedactionPlan ¶
type RedactionPlan struct {
RedactAll bool
// contains filtered or unexported fields
}
RedactionPlan is the redaction decision for a request. RedactAll masks every field/header value wholesale (the RedactPaths equivalent of the .NET SDK's [PinqloqRedactEndpoint]); otherwise ShouldRedact is true for names configured via RedactFields plus the always-redacted floor.
func NewRedactionPlan ¶
func NewRedactionPlan(redactAll bool, declaredNames []string) *RedactionPlan
NewRedactionPlan builds a plan that redacts the given declared field/header names (case insensitive) in addition to the built-in credential-name floor.
func (*RedactionPlan) ContainsDeclaredName ¶
func (p *RedactionPlan) ContainsDeclaredName(body string) bool
ContainsDeclaredName reports whether a raw body mentions one of this plan's declared names, as a whole name.
func (*RedactionPlan) HasDeclaredRedactions ¶
func (p *RedactionPlan) HasDeclaredRedactions() bool
HasDeclaredRedactions reports whether this plan redacts anything beyond the built-in floor.
func (*RedactionPlan) ShouldRedact ¶
func (p *RedactionPlan) ShouldRedact(name string) bool
ShouldRedact reports whether the given JSON field or header name needs to be redacted.
type RequestLoggingOptions ¶
type RequestLoggingOptions struct {
ExcludePaths []string
ResolveDeviceIdentifier func(r *http.Request) string
ResolveAppVersionName func(r *http.Request) string
Metadata map[string]EnricherFunc
Detail map[string]EnricherFunc
RedactFields []string
RedactPaths []string
}
RequestLoggingOptions configures Client.Middleware.