Documentation
¶
Overview ¶
Resurface Go Logger provides tools to log API requests and responses from different Golang web frameworks to a complete API system of record. (https://resurface.io)
Index ¶
- func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request, start time.Time)
- 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) SkipSubmissio() 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 UsageLoggers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendHttpMessage ¶
SendHttpMessage(l *HttpLogger, resp *http.Response, req *http.Request, t time.Time) Uses logger l to send a log of the given resp, req, and t to the loggers url t defines the start time of the logging process used to calculate the logging interval
Types ¶
type HttpLogger ¶ added in v1.1.0
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
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 setup 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) SkipSubmissio ¶
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 specifiy the desired configuration of the logger to be created.
type UsageLoggers ¶
type UsageLoggers struct {
// contains filtered or unexported fields
}
func GetUsageLoggers ¶
func GetUsageLoggers() (*UsageLoggers, error)
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) UrlByDefault ¶
func (uLogger *UsageLoggers) UrlByDefault() string
* * Returns url to use by default.