logger

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvalidOptionMessage

type InvalidOptionMessage struct {
	Option  string
	Message string
}

InvalidOptionMessage represents an issue with the supplied configuration.

type Line

type Line struct {
	Body      string       `json:"line"`
	Timestamp int64        `json:"timestamp"`
	App       string       `json:"app,omitempty"`
	Level     string       `json:"level,omitempty"`
	Env       string       `json:"env,omitempty"`
	Meta      metaEnvelope `json:"meta,omitempty"`
}

Line contains properties related to an individual log message.

type Logger

type Logger struct {
	Options Options
	// contains filtered or unexported fields
}

Logger is the means by which a user can begin to send logs.

func NewLogger

func NewLogger(options Options, key string) (*Logger, error)

NewLogger creates a logger with parametrized options and key. This logger can then be used to send logs into LogDNA.

func (*Logger) Close

func (l *Logger) Close()

Close must be called when finished logging to ensure all buffered logs are sent

func (*Logger) Critical

func (l *Logger) Critical(message string)

Critical logs a message at level Critical to LogDNA.

func (*Logger) Debug

func (l *Logger) Debug(message string)

Debug logs a message at level Debug to LogDNA.

func (*Logger) Error

func (l *Logger) Error(message string)

Error logs a message at level Error to LogDNA.

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

Fatal logs a message at level Fatal to LogDNA.

func (*Logger) Info

func (l *Logger) Info(message string)

Info logs a message at level Info to LogDNA.

func (*Logger) Log

func (l *Logger) Log(message string)

Log sends a provided log message to LogDNA.

func (*Logger) LogWithLevel

func (l *Logger) LogWithLevel(message string, level string) error

LogWithLevel sends a log message to LogDNA with a parameterized level.

func (*Logger) LogWithOptions

func (l *Logger) LogWithOptions(message string, options Options) error

LogWithOptions allows the user to update options uniquely for a given log message before sending the log to LogDNA.

func (*Logger) Warn

func (l *Logger) Warn(message string)

Warn logs a message at level Warn to LogDNA.

type Message

type Message struct {
	Body    string
	Options Options
}

Message represents a single log message and associated options.

type Options

type Options struct {
	App           string
	Env           string
	FlushInterval time.Duration
	SendTimeout   time.Duration
	Hostname      string
	IndexMeta     bool
	IngestURL     string
	IPAddress     string
	Level         string
	MacAddress    string
	MaxBufferLen  int
	Meta          string
	Tags          string
	Timestamp     time.Time
}

Options encapsulates user-provided options such as the Level and App that are passed along with each log.

type Payload

type Payload struct {
	APIKey     string `json:"apikey,omitempty"`
	Hostname   string `json:"hostname,omitempty"`
	IPAddress  string `json:"ip,omitempty"`
	MacAddress string `json:"mac,omitempty"`
	Tags       string `json:"tags,omitempty"`
	Lines      []Line `json:"lines,omitempty"`
}

Payload contains the properties sent to the ingestion endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL