Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BufSize uint = 8192
Set pglogrus.BufSize = <value> _before_ calling NewHook 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 AsyncHook ¶
type AsyncHook struct { *Hook InsertFunc func(*sql.Tx, *logrus.Entry) error // contains filtered or unexported fields }
func NewAsyncHook ¶
NewAsyncHook 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 (*AsyncHook) Fire ¶
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 PostgreSQL
func (*AsyncHook) Flush ¶
func (hook *AsyncHook) Flush()
Flush waits for the log queue to be empty, and then exit the logging loop. This func is meant to be used when the hook was created with NewAsyncHook, and should be used when exiting a program to purge the logs without restarting new DB transactions.
func (*AsyncHook) FlushEvery ¶ added in v1.1.2
LoopDuration sets the internal hook ticker. Every duration d, the hook will send the queued logs to the DB. The default loop duration is 1 second.
type Hook ¶
type Hook struct { Extra map[string]interface{} InsertFunc func(*sql.DB, *logrus.Entry) error // contains filtered or unexported fields }
Hook to send logs to a PostgreSQL database
func (*Hook) AddFilter ¶ added in v1.1.0
func (hook *Hook) AddFilter(fn filter)
AddFilter adds filter that can modify or ignore entry.