Documentation
¶
Overview ¶
Package http allows for log messages to be sent via http.
Example ¶
NOTE: you can use the HTTP handler as a base for creating other handlers
package main import ( stdhttp "net/http" "github.com/go-playground/log" "github.com/go-playground/log/handlers/http" ) func main() { header := make(stdhttp.Header) header.Set("Authorization", "Bearer 378978HJJFEWj73JENEWFN3475") h, err := http.New("https://logs.logserver.com:4565", "POST", header) if err != nil { // handle error, most likely URL parsing error } log.AddHandler(h, log.AllLevels...) // Trace defer log.WithTrace().Info("took this long") log.Debug("debug") log.Info("info") log.Notice("notice") log.Warn("warn") log.Error("error") // log.Panic("panic") // this will panic log.Alert("alert") // log.Fatal("fatal") // this will call os.Exit(1) // logging with fields can be used with any of the above log.WithField("key", "value").Info("test info") }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormatFunc ¶
FormatFunc is the function that the workers use to create a new Formatter per worker allowing reusable go routine safe variable to be used within your Formatter function.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is an instance of the http logger
func (*HTTP) RemoteHost ¶
RemoteHost returns the remote host registered to HTTP
func (*HTTP) SetFormatFunc ¶
func (h *HTTP) SetFormatFunc(fn FormatFunc)
SetFormatFunc sets FormatFunc each worker will call to get a Formatter func
func (*HTTP) SetTimestampFormat ¶
SetTimestampFormat sets HTTP's timestamp output format Default is : "2006-01-02T15:04:05.000000000Z07:00"
func (*HTTP) TimestampFormat ¶
TimestampFormat returns HTTP's current timestamp output format