Documentation
¶
Index ¶
Constants ¶
const (
ChunkSize = 1420
)
Used to control GELF chunking. Should be less than (MTU - len(UDP header)).
TODO: generate dynamically using Path MTU Discovery?
const StackTraceKey = "_stacktrace"
Variables ¶
var BufSize uint = 8192
Set graylog.BufSize = <value> _before_ calling NewGraylogHook Once the buffer is full, logging will start blocking, waiting for slots to be available in the queue.
Functions ¶
func NewTCPReader ¶ added in v3.2.0
func NewTCPReader(addr string) (*net.TCPListener, error)
Types ¶
type CompressType ¶
type CompressType int
What compression type the writer should use when sending messages to the graylog2 server
const ( CompressGzip CompressType = iota CompressZlib NoCompress )
type GELFWriter ¶ added in v3.1.0
func NewWriter ¶
func NewWriter(addr string) (GELFWriter, error)
NewWriter returns a new GELFWriter. This writer can be used to send the output of the standard Go log functions to a central GELF server by passing it to log.SetOutput()
type GraylogHook ¶
type GraylogHook struct { Extra map[string]interface{} Host string Level logrus.Level // contains filtered or unexported fields }
GraylogHook to send logs to a logging service compatible with the Graylog API and the GELF format.
func NewAsyncGraylogHook ¶
func NewAsyncGraylogHook(addr string, extra map[string]interface{}) *GraylogHook
NewAsyncGraylogHook creates a hook to be added to an instance of logger. The hook created will be asynchronous, and it's the responsibility of the user to call the Flush method before exiting to empty the log queue.
func NewGraylogHook ¶
func NewGraylogHook(addr string, extra map[string]interface{}) *GraylogHook
NewGraylogHook creates a hook to be added to an instance of logger.
func (*GraylogHook) Blacklist ¶
func (hook *GraylogHook) Blacklist(b []string)
Blacklist create a blacklist map to filter some message keys. This useful when you want your application to log extra fields locally but don't want graylog to store them.
func (*GraylogHook) Fire ¶
func (hook *GraylogHook) Fire(entry *logrus.Entry) error
Fire is called when a log event is fired. We assume the entry will be altered by another hook, otherwise we might be logging something wrong to Graylog
func (*GraylogHook) Flush ¶
func (hook *GraylogHook) Flush()
Flush waits for the log queue to be empty. This func is meant to be used when the hook was created with NewAsyncGraylogHook.
func (*GraylogHook) Levels ¶
func (hook *GraylogHook) Levels() []logrus.Level
Levels returns the available logging levels.
func (*GraylogHook) SetWriter ¶
func (hook *GraylogHook) SetWriter(w *LowLevelProtocolWriter) error
SetWriter sets the hook Gelf writer
type HTTPWriter ¶ added in v3.1.0
type HTTPWriter struct {
// contains filtered or unexported fields
}
HTTPWriter implements the GELFWriter interface, and cannot be used as an io.Writer
func (HTTPWriter) WriteMessage ¶ added in v3.1.0
func (h HTTPWriter) WriteMessage(m *Message) (err error)
type LowLevelProtocolWriter ¶ added in v3.2.0
type LowLevelProtocolWriter struct { Facility string // defaults to current process name CompressionLevel int // one of the consts from compress/flate CompressionType CompressType // contains filtered or unexported fields }
LowLevelProtocolWriter implements io.Writer and is used to send both discrete messages to a graylog2 server, or data from a stream-oriented interface (like the functions in log).
func (*LowLevelProtocolWriter) Write ¶ added in v3.2.0
func (w *LowLevelProtocolWriter) Write(p []byte) (n int, err error)
Write encodes the given string in a GELF message and sends it to the server specified in NewWriter().
func (*LowLevelProtocolWriter) WriteMessage ¶ added in v3.2.0
func (w *LowLevelProtocolWriter) WriteMessage(m *Message) (err error)
WriteMessage sends the specified message to the GELF server specified in the call to NewWriter(). It assumes all the fields are filled out appropriately. In general, clients will want to use Write, rather than WriteMessage.
type Message ¶
type Message struct { Version string `json:"version"` Host string `json:"host"` Short string `json:"short_message"` Full string `json:"full_message"` TimeUnix float64 `json:"timestamp"` Level int32 `json:"level"` Facility string `json:"facility"` File string `json:"file"` Line int `json:"line"` Extra map[string]interface{} `json:"-"` }
Message represents the contents of the GELF message. It is gzipped before sending.
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}