util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogOff   int = 0
	LogFatal int = 1
	LogError int = 2
	LogWarn  int = 3
	LogInfo  int = 4
	LogDebug int = 5
	LogTrace int = 6
	LogAll   int = 7
)

Logger level constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger - A logger object with support for levelled logging and modular components.

func NewLogger

func NewLogger(stream io.Writer, config LoggerConfig) *Logger

NewLogger - Create and return a new logger object.

func (*Logger) Debugf

func (l *Logger) Debugf(message string, other ...interface{})

Debugf - Print a debug message to the console.

func (*Logger) Debugln

func (l *Logger) Debugln(message string)

Debugln - Print a debug message to the console.

func (*Logger) Errorf

func (l *Logger) Errorf(message string, other ...interface{})

Errorf - Print an error message to the console.

func (*Logger) Errorln

func (l *Logger) Errorln(message string)

Errorln - Print an error message to the console.

func (*Logger) Fatalf

func (l *Logger) Fatalf(message string, other ...interface{})

Fatalf - Print a fatal message to the console. Does NOT cause panic.

func (*Logger) Fatalln

func (l *Logger) Fatalln(message string)

Fatalln - Print a fatal message to the console. Does NOT cause panic.

func (*Logger) Infof

func (l *Logger) Infof(message string, other ...interface{})

Infof - Print an information message to the console.

func (*Logger) Infoln

func (l *Logger) Infoln(message string)

Infoln - Print an information message to the console.

func (*Logger) NewModule

func (l *Logger) NewModule(prefix string) *Logger

NewModule - Creates a new logger object from the previous, using the same configuration, but adds an extra prefix to represent a submodule.

func (*Logger) Tracef

func (l *Logger) Tracef(message string, other ...interface{})

Tracef - Print a trace message to the console.

func (*Logger) Traceln

func (l *Logger) Traceln(message string)

Traceln - Print a trace message to the console.

func (*Logger) Warnf

func (l *Logger) Warnf(message string, other ...interface{})

Warnf - Print a warning message to the console.

func (*Logger) Warnln

func (l *Logger) Warnln(message string)

Warnln - Print a warning message to the console.

type LoggerConfig

type LoggerConfig struct {
	Prefix       string `json:"prefix"`
	LogLevel     string `json:"log_level"`
	AddTimeStamp bool   `json:"add_timestamp"`
}

LoggerConfig - Holds configuration options for a logger object.

func DefaultLoggerConfig

func DefaultLoggerConfig() LoggerConfig

DefaultLoggerConfig - Returns a fully defined logger configuration with the default values for each field.

type Stats

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

Stats - A stats object with capability to hold internal stats as a JSON endpoint, push to statsd, or both.

func NewStats

func NewStats(config StatsConfig) *Stats

NewStats - Create and return a new stats object.

func (*Stats) Close

func (s *Stats) Close()

Close - Stops the stats object from accepting stats and pushing stats to a configured statsd service.

func (*Stats) Decr

func (s *Stats) Decr(stat string, value int64)

Decr - Decrement a stat by a value.

func (*Stats) Gauge

func (s *Stats) Gauge(stat string, value int64)

Gauge - Set a stat as a gauge value.

func (*Stats) GetStats

func (s *Stats) GetStats(timeout time.Duration) (string, error)

GetStats - Returns a string containing the JSON serialized structure of stats at the time of the request.

func (*Stats) Incr

func (s *Stats) Incr(stat string, value int64)

Incr - Increment a stat by a value.

func (*Stats) Timing

func (s *Stats) Timing(stat string, delta int64)

Timing - Set a stat representing a duration.

type StatsConfig

type StatsConfig struct {
	JobBuffer      int64  `json:"job_buffer"`
	RootPath       string `json:"prefix"`
	RetainInternal bool   `json:"retain_internal"`
	StatsDAddress  string `json:"statsd_address"`
}

StatsConfig - Holds configuration options for a stats object.

func DefaultStatsConfig

func DefaultStatsConfig() StatsConfig

DefaultStatsConfig - Returns a fully defined stats configuration with the default values for each field.

type StatsServer

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

StatsServer - A server constructed to present an HTTP endpoint for obtaining live statics regarding the leaps server. Requires a reference to the logger shared with the Curator object at the center of the service.

func NewStatsServer

func NewStatsServer(config StatsServerConfig, logger *Logger, stats *Stats) (*StatsServer, error)

NewStatsServer - Create a new leaps StatsServer.

func (*StatsServer) Listen

func (s *StatsServer) Listen() error

Listen - Bind to the configured http endpoint and begin serving requests.

func (*StatsServer) ServeHTTP

func (s *StatsServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

StatsHandler - The StatsServer request handler.

type StatsServerConfig

type StatsServerConfig struct {
	StaticPath     string `json:"static_path"`
	Path           string `json:"stats_path"`
	Address        string `json:"address"`
	StaticFilePath string `json:"www_dir"`
	StatsTimeout   int    `json:"stat_timeout_ms"`
	RequestTimeout int    `json:"request_timeout_s"`
}

StatsServerConfig - Holds configuration options for the StatsServer

func DefaultStatsServerConfig

func DefaultStatsServerConfig() StatsServerConfig

DefaultStatsServerConfig - Returns a fully defined StatsServer configuration with the default values for each field.

Jump to

Keyboard shortcuts

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