package logrustash
import "github.com/bshuster-repo/logrus-logstash-hook"
Index ¶
- func DefaultFormatter(fields logrus.Fields) logrus.Formatter
- func New(w io.Writer, f logrus.Formatter) logrus.Hook
- type Hook
- type LogstashFormatter
Functions ¶
func DefaultFormatter ¶
DefaultFormatter returns a default Logstash formatter: A JSON format with "@version" set to "1" (unless set differently in `fields`, "type" to "log" (unless set differently in `fields`), "@timestamp" to the log time and "message" to the log message.
Note: to set a different configuration use the `LogstashFormatter` structure.
func New ¶
New returns a new logrus.Hook for Logstash.
To create a new hook that sends logs to `tcp://logstash.corp.io:9999`:
conn, _ := net.Dial("tcp", "logstash.corp.io:9999") hook := logrustash.New(conn, logrustash.DefaultFormatter())
Types ¶
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook represents a Logstash hook. It has two fields: writer to write the entry to Logstash and formatter to format the entry to a Logstash format before sending.
To initialize it use the `New` function.
func (Hook) Fire ¶
Fire takes, formats and sends the entry to Logstash. Hook's formatter is used to format the entry into Logstash format and Hook's writer is used to write the formatted entry to the Logstash instance.
func (Hook) Levels ¶
Levels returns all logrus levels.
type LogstashFormatter ¶
LogstashFormatter represents a Logstash format. It has logrus.Formatter which formats the entry and logrus.Fields which are added to the JSON message if not given in the entry data.
Note: use the `DefaultFormatter` function to set a default Logstash formatter.
func (LogstashFormatter) Format ¶
func (f LogstashFormatter) Format(e *logrus.Entry) ([]byte, error)
Format formats an entry to a Logstash format according to the given Formatter and Fields.
Note: the given entry is copied and not changed during the formatting process.
Source Files ¶
- Version
- v1.1.0 (latest)
- Published
- Oct 30, 2022
- Platform
- js/wasm
- Imports
- 5 packages
- Last checked
- 3 weeks ago –
Tools for package owners.