Documentation ¶
Index ¶
- Variables
- func Debug(format string, a ...interface{})
- func Error(format string, a ...interface{})
- func Fatal(format string, a ...interface{})
- func Info(format string, a ...interface{})
- func Warning(format string, a ...interface{})
- type Config
- type DNSAnswer
- type DNSQuestion
- type DNSRecord
- type DefaultHandler
- func (l *DefaultHandler) AddWriter(w Writer)
- func (l *DefaultHandler) Debug(format string, a ...interface{})
- func (l *DefaultHandler) Error(format string, a ...interface{})
- func (l *DefaultHandler) Fatal(format string, a ...interface{})
- func (l *DefaultHandler) Info(format string, a ...interface{})
- func (l *DefaultHandler) NewMSG() *MSG
- func (l *DefaultHandler) SetWriter(w Writer)
- func (l *DefaultHandler) Warning(format string, a ...interface{})
- func (l *DefaultHandler) WithDNSAnswer(name string, ttl time.Duration, record dns.Record) *MSG
- func (l *DefaultHandler) WithDNSNXDomain() *MSG
- func (l *DefaultHandler) WithDNSQuestions(questions []dns.Question) *MSG
- func (l *DefaultHandler) WithError(err error) *MSG
- func (l *DefaultHandler) WithExitCode(exitCode int) *MSG
- func (l *DefaultHandler) WithField(key string, value interface{}) *MSG
- func (l *DefaultHandler) WithRequest(req *http.Request) *MSG
- func (l *DefaultHandler) WithResponse(res *http.Response) *MSG
- func (l *DefaultHandler) Write(msg *MSG)
- type Format
- type Handler
- type JSONWriter
- type Level
- type MSG
- func NewMSG(l Handler) *MSG
- func WithDNSAnswer(name string, ttl time.Duration, record dns.Record) *MSG
- func WithDNSNXDomain() *MSG
- func WithDNSQuestions(questions []dns.Question) *MSG
- func WithError(err error) *MSG
- func WithExitCode(exitCode int) *MSG
- func WithField(key string, value interface{}) *MSG
- func WithRequest(req *http.Request) *MSG
- func WithResponse(res *http.Response) *MSG
- func (l *MSG) Debug(format string, a ...interface{})
- func (l *MSG) Error(format string, a ...interface{})
- func (l *MSG) Fatal(format string, a ...interface{})
- func (l *MSG) Info(format string, a ...interface{})
- func (l *MSG) JSON() []byte
- func (l *MSG) String() (msg string)
- func (l *MSG) Warning(format string, a ...interface{})
- func (l *MSG) WithDNSAnswer(name string, ttl time.Duration, record dns.Record) *MSG
- func (l *MSG) WithDNSNXDomain() *MSG
- func (l *MSG) WithDNSQuestions(questions []dns.Question) *MSG
- func (l *MSG) WithError(err error) *MSG
- func (l *MSG) WithExitCode(exitCode int) *MSG
- func (l *MSG) WithField(key string, value interface{}) *MSG
- func (l *MSG) WithRequest(req *http.Request) *MSG
- func (l *MSG) WithResponse(res *http.Response) *MSG
- type RequestRecord
- type RequestWriter
- type ResponseRecord
- type TextWriter
- type WebHookWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogger, _ = NewDefaultConfig().GetLogger()
Functions ¶
Types ¶
type Config ¶
type Config struct { Level Level `json:"log_level"` Format Format `json:"log_format"` RequestLogFile string `json:"request_log_file"` WebHookURL string `json:"webhook_url"` }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
func (Config) GetLogger ¶
func (c Config) GetLogger() (handler *DefaultHandler, requestWriter *RequestWriter)
type DNSQuestion ¶
type DNSQuestion struct { Name string `json:"name"` Type string `json:"type"` Class string `json:"class"` }
func (*DNSQuestion) Load ¶
func (q *DNSQuestion) Load(question dns.Question)
type DNSRecord ¶
type DNSRecord struct { Questions []*DNSQuestion `json:"questions"` Answers []*DNSAnswer `json:"answers"` }
func (*DNSRecord) AddNXDomain ¶
func (d *DNSRecord) AddNXDomain()
func (*DNSRecord) AddQuestions ¶
type DefaultHandler ¶
func NewHandler ¶
func NewHandler(level Level) *DefaultHandler
func (*DefaultHandler) AddWriter ¶
func (l *DefaultHandler) AddWriter(w Writer)
func (*DefaultHandler) Debug ¶
func (l *DefaultHandler) Debug(format string, a ...interface{})
func (*DefaultHandler) Error ¶
func (l *DefaultHandler) Error(format string, a ...interface{})
func (*DefaultHandler) Fatal ¶
func (l *DefaultHandler) Fatal(format string, a ...interface{})
func (*DefaultHandler) Info ¶
func (l *DefaultHandler) Info(format string, a ...interface{})
func (*DefaultHandler) NewMSG ¶
func (l *DefaultHandler) NewMSG() *MSG
func (*DefaultHandler) SetWriter ¶
func (l *DefaultHandler) SetWriter(w Writer)
func (*DefaultHandler) Warning ¶
func (l *DefaultHandler) Warning(format string, a ...interface{})
func (*DefaultHandler) WithDNSAnswer ¶
func (*DefaultHandler) WithDNSNXDomain ¶
func (l *DefaultHandler) WithDNSNXDomain() *MSG
func (*DefaultHandler) WithDNSQuestions ¶
func (l *DefaultHandler) WithDNSQuestions(questions []dns.Question) *MSG
func (*DefaultHandler) WithError ¶
func (l *DefaultHandler) WithError(err error) *MSG
func (*DefaultHandler) WithExitCode ¶
func (l *DefaultHandler) WithExitCode(exitCode int) *MSG
func (*DefaultHandler) WithField ¶
func (l *DefaultHandler) WithField(key string, value interface{}) *MSG
func (*DefaultHandler) WithRequest ¶
func (l *DefaultHandler) WithRequest(req *http.Request) *MSG
func (*DefaultHandler) WithResponse ¶
func (l *DefaultHandler) WithResponse(res *http.Response) *MSG
func (*DefaultHandler) Write ¶
func (l *DefaultHandler) Write(msg *MSG)
type Handler ¶
type Handler interface { SetWriter(Writer) AddWriter(Writer) Write(*MSG) WithExitCode(int) *MSG WithError(error) *MSG WithField(string, interface{}) *MSG WithRequest(*http.Request) *MSG Info(string, ...interface{}) Debug(string, ...interface{}) Fatal(string, ...interface{}) Warning(string, ...interface{}) Error(string, ...interface{}) }
type JSONWriter ¶
type JSONWriter struct {
// contains filtered or unexported fields
}
func (*JSONWriter) SetLevel ¶
func (w *JSONWriter) SetLevel(level Level)
func (*JSONWriter) Write ¶
func (w *JSONWriter) Write(msg *MSG) error
type MSG ¶
type MSG struct { Timestamp time.Time `json:"timestamp"` Message string `json:"message"` Fields map[string]interface{} `json:"fields,omitempty"` Request *RequestRecord `json:"request,omitempty"` Response *ResponseRecord `json:"response,omitempty"` DNS *DNSRecord `json:"dns,omitempty"` ErrorMessage string `json:"error,omitempty"` Level Level `json:"level"` // contains filtered or unexported fields }
func WithDNSNXDomain ¶
func WithDNSNXDomain() *MSG
func WithDNSQuestions ¶
func WithExitCode ¶
func WithRequest ¶
func WithResponse ¶
func (*MSG) WithDNSAnswer ¶
func (*MSG) WithDNSNXDomain ¶
func (*MSG) WithExitCode ¶
type RequestRecord ¶
type RequestRecord struct { Method string URL *url.URL Proto string ProtoMajor int ProtoMinor int Header map[string][]string Body string ContentLength int64 TransferEncoding []string Host string Form url.Values PostForm url.Values MultipartForm *multipart.Form Trailer map[string][]string RemoteAddr string RequestURI string TLS bool TimeStamp time.Time // contains filtered or unexported fields }
func (*RequestRecord) MarshalJSON ¶
func (r *RequestRecord) MarshalJSON() ([]byte, error)
func (*RequestRecord) ReadBody ¶
func (r *RequestRecord) ReadBody() error
type RequestWriter ¶
type RequestWriter struct { RequestLogFile string `json:"request_log_file"` // contains filtered or unexported fields }
func (*RequestWriter) Close ¶
func (w *RequestWriter) Close() error
func (*RequestWriter) SetLevel ¶
func (w *RequestWriter) SetLevel(level Level)
func (*RequestWriter) Write ¶
func (w *RequestWriter) Write(msg *MSG) (err error)
type ResponseRecord ¶
type ResponseRecord struct { Status string StatusCode int Proto string ProtoMajor int ProtoMinor int Header http.Header Body string ContentLength int64 TransferEncoding []string Uncompressed bool Trailer http.Header TLS bool TimeStamp time.Time // contains filtered or unexported fields }
func (*ResponseRecord) MarshalJSON ¶
func (r *ResponseRecord) MarshalJSON() ([]byte, error)
func (*ResponseRecord) ReadBody ¶
func (r *ResponseRecord) ReadBody() error
type TextWriter ¶
type TextWriter struct {
// contains filtered or unexported fields
}
func (*TextWriter) SetLevel ¶
func (w *TextWriter) SetLevel(level Level)
func (*TextWriter) Write ¶
func (w *TextWriter) Write(msg *MSG) error
type WebHookWriter ¶
type WebHookWriter struct { WebHookURL string `json:"webhook_url"` // contains filtered or unexported fields }
func (*WebHookWriter) SetLevel ¶
func (w *WebHookWriter) SetLevel(level Level)
func (*WebHookWriter) Write ¶
func (w *WebHookWriter) Write(msg *MSG) error
Click to show internal directories.
Click to hide internal directories.