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?
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 ¶
This section is empty.
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 )
type GraylogHook ¶
type GraylogHook struct { Extra map[string]interface{} // contains filtered or unexported fields }
GraylogHook to send logs to a logging service compatible with the Graylog API and the GELF format.
func NewAsyncGraylogHook ¶ added in v1.1.0
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 logging something wrong to Graylog
func (*GraylogHook) Flush ¶ added in v1.1.0
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 *Writer) error
SetWriter sets the hook Gelf Writer
func (*GraylogHook) Writer ¶
func (hook *GraylogHook) Writer() *Writer
Writer returns the logger Gelf Writer
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
}
func (*Reader) ReadMessage ¶
type Writer ¶
type Writer struct { Facility string // defaults to current process name CompressionLevel int // one of the consts from compress/flate CompressionType CompressType // contains filtered or unexported fields }
Writer 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 NewWriter ¶
New returns a new GELF Writer. 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()
func (*Writer) Write ¶
Write encodes the given string in a GELF message and sends it to the server specified in New().
func (*Writer) WriteMessage ¶
WriteMessage sends the specified message to the GELF server specified in the call to New(). It assumes all the fields are filled out appropriately. In general, clients will want to use Write, rather than WriteMessage.