Documentation

Index

Constants

View Source
const (
	LogLevelDebug = "Debug"
	LogLevelTrace = "Trace"
	LogLevelInfo  = "Info"
	LogLevelWarn  = "Warn"
	LogLevelError = "Error"
	LogLevelFatal = "Fatal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

    Client handles logging to LogDNA.

    func New

    func New(conf Config) (*Client, error)

      New creates initialized *Client.

      func (*Client) Debug

      func (c *Client) Debug(line string, opt ...map[string]interface{}) error

        Debug sends a debug level log.

        func (*Client) Emit

        func (c *Client) Emit(line string, opt ...map[string]interface{}) error

          Emit sends a log.

          func (*Client) EmitWithLevel

          func (c *Client) EmitWithLevel(level, line string, opt ...map[string]interface{}) error

            Emit sends a log of a given level.

            func (*Client) Err

            func (c *Client) Err(line string, opt ...map[string]interface{}) error

              Err sends a error level log.

              func (*Client) Fatal

              func (c *Client) Fatal(line string, opt ...map[string]interface{}) error

                Fatal sends a fatal level log.

                func (*Client) Info

                func (c *Client) Info(line string, opt ...map[string]interface{}) error

                  Info sends a info level log.

                  func (*Client) RunDaemon

                  func (c *Client) RunDaemon(size int, interval time.Duration)

                    RunDaemon runs a Daemon in background.

                    func (*Client) Trace

                    func (c *Client) Trace(line string, opt ...map[string]interface{}) error

                      Trace sends a trace level log.

                      func (*Client) Warn

                      func (c *Client) Warn(line string, opt ...map[string]interface{}) error

                        Warn sends a warning level log.

                        type Config

                        type Config struct {
                        	APIKey string
                        
                        	App      string
                        	Env      string
                        	Hostname string
                        	IP       string
                        	MacAddr  string
                        
                        	Tags []string
                        
                        	MinimumLevel   string
                        	Sync           bool
                        	Debug          bool
                        	NoRetry        bool
                        	Timeout        time.Duration
                        	CustomEndpoint string
                        
                        	CheckpointSize     int
                        	CheckpointInterval time.Duration
                        	// contains filtered or unexported fields
                        }

                          Config contains parameters for LogDNA.

                          func (*Config) Init

                          func (c *Config) Init() error

                            Init intializes a config.

                            func (Config) Validate

                            func (c Config) Validate() error

                            type Daemon

                            type Daemon struct {
                            	// contains filtered or unexported fields
                            }

                              Daemon is background daemon for sending logs. This struct stores logs and sends log to LogDNA in each checkpoint timing.

                              func NewDaemon

                              func NewDaemon(size int, interval time.Duration, fn func([]*logPayload) error) *Daemon

                                NewDaemon creates new Daemon. size is number of logs to send LogDNA API in single checkpoint. interval is the time of checkpoint interval. fn is function called in each checkpoint, to sends logs to LogDNA API.

                                func (*Daemon) Add

                                func (d *Daemon) Add(logs ...*logPayload)

                                  Add adds log data into daemon.

                                  func (*Daemon) Flush

                                  func (d *Daemon) Flush()

                                    Flush gets logs from the internal spool and execute flushLogs function.

                                    func (*Daemon) Run

                                    func (d *Daemon) Run()

                                      Run sets timer to flush data in each checkpoint as a background daemon.

                                      func (*Daemon) Stop

                                      func (d *Daemon) Stop()

                                        Stop stops daemon.

                                        type LogData

                                        type LogData struct {
                                        	Time    time.Time
                                        	Message string
                                        
                                        	Level string
                                        	App   string
                                        	Env   string
                                        	Meta  map[string]interface{}
                                        }

                                        func (LogData) GetTime

                                        func (d LogData) GetTime() int64