Documentation ¶
Overview ¶
Package logger-go from resurface.io provides tools to log API requests and responses from different Golang web frameworks to a complete API system of record. (https://resurface.io)
Index ¶
- Variables
- func MockGetBrotliResponse(request *http.Request) http.Response
- func MockGetDeflateResponse(request *http.Request) http.Response
- func MockGetGzipResponse(request *http.Request) http.Response
- func MockGetJPEGResponse(request *http.Request) http.Response
- func MockGetJSONEncodedResponse(request *http.Request, encoding string) http.Response
- func MockGetJSONResponse(request *http.Request) http.Response
- func MockGetNoBodyRequest() http.Request
- func MockGetNoBodyResponse(request *http.Request) http.Response
- func MockGetPlainTextResponse(request *http.Request) http.Response
- func MockGetRequestWithBody(body []byte, mimeType string) http.Request
- func MockGetResponseWithBody(request *http.Request, body []byte, mimeType string) http.Response
- func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request, now int64, ...)
- type HttpLogger
- type HttpLoggerForMux
- type HttpRule
- type HttpRules
- func (rules *HttpRules) AllowHttpUrl() bool
- func (rules *HttpRules) CopySessionField() []*HttpRule
- func (rules *HttpRules) DebugRules() string
- func (rules *HttpRules) DefaultRules() string
- func (rules *HttpRules) Remove() []*HttpRule
- func (rules *HttpRules) RemoveIf() []*HttpRule
- func (rules *HttpRules) RemoveIfFound() []*HttpRule
- func (rules *HttpRules) RemoveUnless() []*HttpRule
- func (rules *HttpRules) RemoveUnlessFound() []*HttpRule
- func (rules *HttpRules) Replace() []*HttpRule
- func (rules *HttpRules) Sample() []*HttpRule
- func (rules *HttpRules) SetDefaultRules(r string)
- func (rules *HttpRules) Size() int
- func (rules *HttpRules) SkipCompression() bool
- func (rules *HttpRules) SkipSubmission() bool
- func (rules *HttpRules) StandardRules() string
- func (rules *HttpRules) Stop() []*HttpRule
- func (rules *HttpRules) StopIf() []*HttpRule
- func (rules *HttpRules) StopIfFound() []*HttpRule
- func (rules *HttpRules) StopUnless() []*HttpRule
- func (rules *HttpRules) StopUnlessFound() []*HttpRule
- func (rules *HttpRules) StrictRules() string
- func (rules *HttpRules) Text() string
- type NetHttpClientLogger
- func (clientLogger *NetHttpClientLogger) CloseIdleConnections()
- func (clientLogger *NetHttpClientLogger) Do(req *http.Request) (resp *http.Response, err error)
- func (clientLogger *NetHttpClientLogger) Get(url string) (resp *http.Response, err error)
- func (clientLogger *NetHttpClientLogger) Head(url string) (resp *http.Response, err error)
- func (logger *NetHttpClientLogger) Logger() *HttpLogger
- func (clientLogger *NetHttpClientLogger) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
- func (clientLogger *NetHttpClientLogger) PostForm(url string, data url.Values) (resp *http.Response, err error)
- type Options
- type TLSConfig
- type UsageLoggers
Constants ¶
This section is empty.
Variables ¶
var LIMIT = 1024 * 1024
Functions ¶
func MockGetBrotliResponse ¶ added in v3.2.3
func MockGetDeflateResponse ¶ added in v3.2.3
func MockGetGzipResponse ¶ added in v3.2.3
func MockGetJPEGResponse ¶ added in v3.2.3
func MockGetJSONEncodedResponse ¶ added in v3.2.3
func MockGetJSONResponse ¶ added in v3.2.3
func MockGetNoBodyRequest ¶ added in v3.2.3
func MockGetNoBodyResponse ¶ added in v3.2.3
func MockGetPlainTextResponse ¶ added in v3.2.3
func MockGetRequestWithBody ¶ added in v3.2.3
func MockGetResponseWithBody ¶ added in v3.2.3
func SendHttpMessage ¶
func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request, now int64, interval int64, customFields map[string]string)
SendHttpMessage(l *HttpLogger, resp *http.Response, req *http.Request, now int64, interval int64) Uses logger l to send a log of the given resp and req to the loggers url here, now refers to the time at which the request was received and interval corresponds to the time between request and response. customFields are used to pass custom information fields through the logger to Resurface.
Types ¶
type HttpLogger ¶
type HttpLogger struct {
// contains filtered or unexported fields
}
HttpLogger is the struct contains a pointer to a baseLogger instance and a set of rules used to define the behaviour of the logger.
func NewHttpLogger ¶
func NewHttpLogger(options Options) (*HttpLogger, error)
NewHttpLogger returns a pointer to a new HttpLogger object, with the given options applied, and an error
func (*HttpLogger) Stop ¶ added in v3.3.1
func (logger *HttpLogger) Stop()
type HttpLoggerForMux ¶
type HttpLoggerForMux struct { HttpLogger *HttpLogger // contains filtered or unexported fields }
HttpLoggerForMux defines a struct used to log specifically gorilla/mux apps
func NewHttpLoggerForMux ¶
func NewHttpLoggerForMux() (*HttpLoggerForMux, error)
NewHttpLoggerForMux returns a pointer to an instance of an HttpLoggerForMux struct with the default options applied and an error. If there is no error, the error value returned will be nil.
func NewHttpLoggerForMuxOptions ¶
func NewHttpLoggerForMuxOptions(options Options) (*HttpLoggerForMux, error)
NewHttpLoggerForMuxOptions(o Options) returns a pointer to a HttpLoggerForMux struct with the given options o applied and an error. If there is no error, the error value returned will be nil.
func (HttpLoggerForMux) LogData ¶
func (muxLogger HttpLoggerForMux) LogData(next http.Handler) http.Handler
LogData() takes 1 argument of type http.Handler and returns an object of the same type, http.Handler. This function is intended to be used in a Middleware function in a gorilla/mux server. For details on how to set up Middleware for a mux server see: https://github.com/resurfaceio/logger-go#logging_from_mux
type HttpRules ¶
type HttpRules struct {
// contains filtered or unexported fields
}
struct for rules that are applied to http logging messages
func GetHttpRules ¶
func GetHttpRules() *HttpRules
get package global httpRules containing default rules sets
func (*HttpRules) AllowHttpUrl ¶
func (*HttpRules) CopySessionField ¶
func (*HttpRules) DebugRules ¶
func (*HttpRules) DefaultRules ¶
func (*HttpRules) RemoveIfFound ¶
func (*HttpRules) RemoveUnless ¶
func (*HttpRules) RemoveUnlessFound ¶
func (*HttpRules) SetDefaultRules ¶
*HttpRules.SetDefaultRules(r string) sets the default rules of the logger to rule(s) r
func (*HttpRules) SkipCompression ¶
func (*HttpRules) SkipSubmission ¶ added in v3.3.1
func (*HttpRules) StandardRules ¶
func (*HttpRules) StopIfFound ¶
func (*HttpRules) StopUnless ¶
func (*HttpRules) StopUnlessFound ¶
func (*HttpRules) StrictRules ¶
type NetHttpClientLogger ¶
type NetHttpClientLogger struct { http.Client HttpLogger *HttpLogger }
NetHttpClientLogger defines a struct used to log specifically from the client side of API interactions using the net/http package.
func NewNetHttpClientLogger ¶
func NewNetHttpClientLogger() (*NetHttpClientLogger, error)
NewNetHttpClientLogger() takes no arguments and returns 2 objects; a pointer to an instance of an NetHttpClientLogger struct and an error. The NetHttpClientLogger returned by this function has the default options applied. If there is no error, the error value returned will be nil.
func NewNetHttpClientLoggerOptions ¶
func NewNetHttpClientLoggerOptions(options Options) (*NetHttpClientLogger, error)
NewNetHttpClientLoggerOptions() takes 1 argument of type logger.Options and returns 2 objects; a pointer to an instance of an NetHttpClientLogger struct and an error. The NetHttpClientLogger returned by this function has the given options applied. If there is no error, the error value returned will be nil.
func (*NetHttpClientLogger) CloseIdleConnections ¶
func (clientLogger *NetHttpClientLogger) CloseIdleConnections()
net.http.Client.CloseIdleConnections() wrapper
func (*NetHttpClientLogger) Get ¶
func (clientLogger *NetHttpClientLogger) Get(url string) (resp *http.Response, err error)
net.http.Client.Get wrapper with logging
func (*NetHttpClientLogger) Head ¶
func (clientLogger *NetHttpClientLogger) Head(url string) (resp *http.Response, err error)
net.http.Client.Head wrapper with logging
func (*NetHttpClientLogger) Logger ¶
func (logger *NetHttpClientLogger) Logger() *HttpLogger
type Options ¶
type Options struct { //Rules defines the rules that will be applied to the logger. Rules string //Url defines the Url the logger will send the logs to. Url string //Enabled defines the state of the logger; enabled or disabled. Enabled interface{} //Queue is a slice of strings used to store logs; exclusively for testing purposes. //Queue must be nil for the logger to properly function. Queue []string }
Options struct is passed to a "NewLogger" function to specify the desired configuration of the logger to be created.
type TLSConfig ¶ added in v3.4.0
type TLSConfig struct {
// contains filtered or unexported fields
}
type UsageLoggers ¶
type UsageLoggers struct {
// contains filtered or unexported fields
}
func GetUsageLoggers ¶
func GetUsageLoggers() (*UsageLoggers, error)
func (*UsageLoggers) ConfigByDefault ¶ added in v3.3.1
func (uLogger *UsageLoggers) ConfigByDefault() map[string]int
* * Returns additional configuration for the base logger
func (*UsageLoggers) Disable ¶
func (uLogger *UsageLoggers) Disable()
* * Disable all usage loggers.
func (*UsageLoggers) Enable ¶
func (uLogger *UsageLoggers) Enable()
* * Enable all usage loggers, except those explicitly disabled.
func (*UsageLoggers) IsEnabled ¶
func (uLogger *UsageLoggers) IsEnabled() bool
* * Returns true if usage loggers are generally enabled.
func (*UsageLoggers) TLSConfigByDefault ¶ added in v3.4.0
func (uLogger *UsageLoggers) TLSConfigByDefault() TLSConfig
* * Returns additional TLS configuration for the internal http client
func (*UsageLoggers) UrlByDefault ¶
func (uLogger *UsageLoggers) UrlByDefault() string
* * Returns url to use by default.