logler

package module
v0.0.0-...-8816289 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2015 License: MIT Imports: 10 Imported by: 0

README

logler

  • logs to both stdout/stderror and to loggly
  • sample rate for loggly (write only x% of requests to save money), except for emergency log level
  • accepts json messages only for loggly, log api for trace
  • output: LOG-LEVEL: yyyy/MM/dd hh:mm:ss message
  • Trace/Info/Warn/Error/Emergency API
  • automatically include file, line number and function name in logs

usage

type JSON map[string]interface{}
func main() {
	logger = logler.New(&logler.Options{
		LogglyToken: "311-234324-2323-234324-2323423",
		Component:   "my-cool-server",
		LogglySampleRate: 25 // (1-100), write only 25% of logs to loggly
	})

	logger.Warn(JSON{"category": "test", "action": "foo", "label": "bar"})
}

results in stdout:

WARNING: 2015/03/27 16:39:30 {"action":"foo","category":"test","label":"bar"}

license

MIT (see LICENSE file)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Trace *log.Logger
	// contains filtered or unexported fields
}

func New

func New(opts *Options) *Client

func (*Client) Emergency

func (c *Client) Emergency(msg map[string]interface{})

func (*Client) Error

func (c *Client) Error(msg map[string]interface{})

func (*Client) Info

func (c *Client) Info(msg map[string]interface{})

func (*Client) Warn

func (c *Client) Warn(msg map[string]interface{})

type Options

type Options struct {
	LogglyToken      string
	Component        string
	LogglySampleRate int
	LogglyBufferSize int
	MinimalLog       bool
}

Jump to

Keyboard shortcuts

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