Documentation ¶
Index ¶
- func CreateLogger(logger io.Writer, listenPort int, pretty bool) func(http.Handler) http.Handler
- func GetOutboundIP() net.IP
- func NewRelicLogger(appName, license string) func(http.Handler) http.Handler
- func TransactionFromContext(ctx context.Context) string
- func TransactionHandler(header string) func(http.Handler) http.Handler
- func TxnFields(r *http.Request) log.Fields
- type NoopWriter
- type ScalyrWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateLogger ¶
CreateLogger creates an access logger
func NewRelicLogger ¶
NewRelicLogger creates a New Relic logger handler using the provided API credentials. Currently NewRelicLogger relies on functionality provided by gorilla/mux to retrieve the path template.
func TransactionFromContext ¶
TransactionFromContext retrieves the txnID from the given context.
func TransactionHandler ¶
TransactionHandler creates a unique ID for every request.
Types ¶
type NoopWriter ¶
type NoopWriter struct{}
NoopWriter satisfies the io.Writer interface, but does nothing.
type ScalyrWriter ¶
type ScalyrWriter struct {
// contains filtered or unexported fields
}
ScalyrWriter will buffer all log writes for logging to scalyr, then tee all calls to the supplied io.Writer
func CreateScalyrWriter ¶
func CreateScalyrWriter(tee io.Writer, url string) *ScalyrWriter
CreateScalyrWriter will create an io.Writer which will tee all log writes between the supplied io.Writer and a buffer. You can then call go ScalyrWriter.Log with a supplied interval. On that interval, all collected logs will be sent to Scalyr
URL Takes the following form, which requires the user to fill out the Host, Logfile, Access Token and Parser ex: https://www.scalyr.com/api/uploadLogs?host=my-host-name&logfile=myErrorLog&token=myScalyrToken&parser=goErrorLog
Logs are POST'd in batches to Scalyr based on the interval provided to the Update function. Use logging.NoopWriter if you wish to ONLY log to Scalyr
func (*ScalyrWriter) Println ¶
func (w *ScalyrWriter) Println(msg ...string)
Println writes a log message out to the defined TEE writer. Anything sent to Println will *NOT* be sent to scalyr.
func (*ScalyrWriter) Update ¶
func (w *ScalyrWriter) Update(interval int)
Update periodically polls the current writer's buffer and uploads the logs to Scalyr. Interval should be provided in Milliseconds.
Example usage: w := CreateScalyrWriter(os.Stdout, "https://www.scalyr.com/api/uploadLogs?host=ExampleService&logfile=AccessLog&token=ExampleToken") go w.Update(2000) // Update every 2 seconds. Client timeout is set to 2 seconds, it's not recommended that the update interval be less than 2s.
func (*ScalyrWriter) UpdateNow ¶
func (w *ScalyrWriter) UpdateNow()
UpdateNow immediately uploads the collected logs to Scalyr. Interval should be provided in Milliseconds.
Example usage: w := CreateScalyrWriter(os.Stdout, "https://www.scalyr.com/api/uploadLogs?host=ExampleService&logfile=AccessLog&token=ExampleToken") defer w.UpdateNow() // Update after leaving the current function.