package test
import "github.com/sirupsen/logrus/hooks/test"
The Test package is used for testing logrus. It provides a simple hooks which register logged messages.
Index ¶
- type Hook
- func NewGlobal() *Hook
- func NewLocal(logger *logrus.Logger) *Hook
- func NewNullLogger() (*logrus.Logger, *Hook)
- func (t *Hook) AllEntries() []*logrus.Entry
- func (t *Hook) Fire(e *logrus.Entry) error
- func (t *Hook) LastEntry() *logrus.Entry
- func (t *Hook) Levels() []logrus.Level
- func (t *Hook) Reset()
Types ¶
type Hook ¶
type Hook struct { // Entries is an array of all entries that have been received by this hook. // For safe access, use the AllEntries() method, rather than reading this // value directly. Entries []logrus.Entry // contains filtered or unexported fields }
Hook is a hook designed for dealing with logs in test scenarios.
func NewGlobal ¶
func NewGlobal() *Hook
NewGlobal installs a test hook for the global logger.
func NewLocal ¶
NewLocal installs a test hook for a given local logger.
func NewNullLogger ¶
NewNullLogger creates a discarding logger and installs the test hook.
func (*Hook) AllEntries ¶
AllEntries returns all entries that were logged.
func (*Hook) Fire ¶
func (*Hook) LastEntry ¶
LastEntry returns the last entry that was logged or nil.
func (*Hook) Levels ¶
func (*Hook) Reset ¶
func (t *Hook) Reset()
Reset removes all Entries from this test hook.
Source Files ¶
- Version
- v1.9.3 (latest)
- Published
- May 21, 2023
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 18 hours ago –
Tools for package owners.