bunyan

package module
v0.0.0-...-53fe981 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2015 License: MIT Imports: 15 Imported by: 1

README

go-bunyan

Documentation

Index

Constants

View Source
const (
	Fatal LogLevel = 60
	Error          = 50
	Warn           = 40
	Info           = 30
	Debug          = 20
	Trace          = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BugsnagStream

type BugsnagStream struct {
	*Stream
}

func NewBugsnagStream

func NewBugsnagStream(minLogLevel LogLevel, filter StreamFilter) (result *BugsnagStream)

func (*BugsnagStream) Publish

func (s *BugsnagStream) Publish(l *LogEntry)

type EmailStream

type EmailStream struct {
	*Stream
	// contains filtered or unexported fields
}

func NewEmailStream

func NewEmailStream(minLogLevel LogLevel, filter StreamFilter, templateSource string, recipient, mailServer string, minimumInterval time.Duration) (result *EmailStream)

func (*EmailStream) Publish

func (s *EmailStream) Publish(l *LogEntry)

type FileStream

type FileStream struct {
	*Stream
	// contains filtered or unexported fields
}

func NewFileStream

func NewFileStream(minLogLevel LogLevel, filter StreamFilter, path string) (result *FileStream, err error)

func (*FileStream) Publish

func (s *FileStream) Publish(l *LogEntry)

type LogEntry

type LogEntry struct {
	Data        interface{} `json:"data,omitempty"`
	Error       string      `json:"error,omitempty"`
	Hostname    string      `json:"hostname"`
	Level       LogLevel    `json:"level"`
	Message     string      `json:"msg"`
	Name        string      `json:"name"`
	ProcessID   int         `json:"pid"`
	Request     *Request    `json:"req,omitempty"`
	Response    *Response   `json:"res,omitempty"`
	StackTrace  string      `json:"trace,omitempty"`
	Time        time.Time   `json:"time"`
	CompletedIn string      `json:"completed_in,omitempty"`
	Version     int         `json:"v"`
}

func NewLogEntry

func NewLogEntry(level LogLevel, message string) *LogEntry

func (*LogEntry) SetCompletedIn

func (l *LogEntry) SetCompletedIn(completedIn string)

func (*LogEntry) SetData

func (l *LogEntry) SetData(data interface{})

func (*LogEntry) SetRequest

func (l *LogEntry) SetRequest(r *http.Request)

func (*LogEntry) SetRequestBody

func (l *LogEntry) SetRequestBody(body []byte)

func (*LogEntry) SetResponseBody

func (l *LogEntry) SetResponseBody(body []byte)

func (*LogEntry) SetResponseError

func (l *LogEntry) SetResponseError(err error)

func (*LogEntry) SetResponseStatusCode

func (l *LogEntry) SetResponseStatusCode(statusCode int)

func (*LogEntry) SetStackTrace

func (l *LogEntry) SetStackTrace(trace string)

func (*LogEntry) String

func (l *LogEntry) String() string

type LogLevel

type LogLevel int

type Logger

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

func NewLogger

func NewLogger(name string, streams []StreamInterface) *Logger

Creates a new logger, given one or more streams

func (*Logger) AddStream

func (l *Logger) AddStream(s StreamInterface)

func (*Logger) Debug

func (l *Logger) Debug(message string) *LogEntry

func (*Logger) DebugF

func (l *Logger) DebugF(format string, values ...interface{}) *LogEntry

func (*Logger) Error

func (l *Logger) Error(message string) *LogEntry

func (*Logger) ErrorF

func (l *Logger) ErrorF(format string, values ...interface{}) *LogEntry

func (*Logger) Fatal

func (l *Logger) Fatal(message string) *LogEntry

func (*Logger) FatalF

func (l *Logger) FatalF(format string, values ...interface{}) *LogEntry

func (*Logger) Info

func (l *Logger) Info(message string) *LogEntry

func (*Logger) InfoF

func (l *Logger) InfoF(format string, values ...interface{}) *LogEntry

func (*Logger) Log

func (l *Logger) Log(e *LogEntry)

func (*Logger) LogF

func (l *Logger) LogF(level LogLevel, format string, values ...interface{}) *LogEntry

func (*Logger) Logln

func (l *Logger) Logln(level LogLevel, message string) *LogEntry

func (*Logger) Println

func (l *Logger) Println(val interface{})

func (*Logger) SetGlobalMinLogLevel

func (l *Logger) SetGlobalMinLogLevel(minLogLevel LogLevel)

func (*Logger) SetSynchronous

func (l *Logger) SetSynchronous(sync bool)

func (*Logger) Trace

func (l *Logger) Trace(message string) *LogEntry

func (*Logger) TraceF

func (l *Logger) TraceF(format string, values ...interface{}) *LogEntry

func (*Logger) Warn

func (l *Logger) Warn(message string) *LogEntry

func (*Logger) WarnF

func (l *Logger) WarnF(format string, values ...interface{}) *LogEntry

type Request

type Request struct {
	Method        string      `json:"method"`
	URL           string      `json:"url"`
	Headers       http.Header `json:"headers"`
	RemoteAddress string      `json:"remoteAddress"`
	Body          interface{} `json:"body,omitempty"`
}

type Response

type Response struct {
	StatusCode int         `json:"statusCode,omitempty"`
	Headers    http.Header `json:"headers,omitempty"`
	Body       interface{} `json:"body,omitempty"`
}

type StdoutStream

type StdoutStream struct {
	*Stream
}

func NewStdoutStream

func NewStdoutStream(minLogLevel LogLevel, filter StreamFilter) *StdoutStream

func (*StdoutStream) Publish

func (s *StdoutStream) Publish(l *LogEntry)

type Stream

type Stream struct {
	MinLogLevel LogLevel
	Filter      StreamFilter
}

type StreamFilter

type StreamFilter func(*LogEntry) bool

func FilterGenerator

func FilterGenerator(minStatusCode, maxStatusCode int, excludeStatusCodes []int, allowRequestBody, allowResponseBody bool) StreamFilter

type StreamInterface

type StreamInterface interface {
	Publish(*LogEntry)
}

Jump to

Keyboard shortcuts

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