util

package
v0.0.0-...-42df541 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2014 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRITICAL = iota
	ERROR
	WARNING
	INFO
	DEBUG
)

Message levels

Variables

This section is empty.

Functions

func GenUUID4

func GenUUID4() (string, error)

func GetAWSPublicHostname

func GetAWSPublicHostname() (hostname string, err error)

Get the public AWS hostname for this machine. * TODO: Make this a generic utility for getting public info from * the aws meta server?

func ScanUUID

func ScanUUID(uuids string) ([]byte, error)

Types

type Fields

type Fields map[string]string

The fields to relay. NOTE: object reflection is VERY CPU expensive. I specify strings here to reduce that as much as possible. Please do not change this to something like map[string]interface{} since that can dramatically increase server load.

type HekaLogger

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

func NewHekaLogger

func NewHekaLogger(conf *MzConfig) *HekaLogger

Create a new Heka logging interface.

func (HekaLogger) Critical

func (self HekaLogger) Critical(mtype, msg string, fields Fields) (err error)

record the Highest priority message, and include a printstack to STDERR

func (HekaLogger) Debug

func (self HekaLogger) Debug(mtype, msg string, fields Fields) (err error)

func (HekaLogger) Error

func (self HekaLogger) Error(mtype, msg string, fields Fields) (err error)

func (HekaLogger) Info

func (self HekaLogger) Info(mtype, msg string, fields Fields) (err error)

record the lowest priority message

func (HekaLogger) Log

func (self HekaLogger) Log(level int32, mtype, payload string, fields Fields) (err error)

Logging workhorse function. Chances are you're not going to call this directly, but via one of the helper methods. of Info() .. Critical() level - One of the defined logging CONST values mtype - Message type, Short class identifier for the message payload - Main error message fields - additional optional key/value data associated with the message.

func (HekaLogger) Warn

func (self HekaLogger) Warn(mtype, msg string, fields Fields) (err error)

type HekaStdoutSender

type HekaStdoutSender struct{}

func (*HekaStdoutSender) Close

func (h *HekaStdoutSender) Close()

func (*HekaStdoutSender) SendMessage

func (h *HekaStdoutSender) SendMessage(outBytes []byte) (err error)

type JsMap

type JsMap map[string]interface{}

type Metrics

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

func NewMetrics

func NewMetrics(prefix string, logger *HekaLogger, config *MzConfig) (self *Metrics)

func (*Metrics) Decrement

func (self *Metrics) Decrement(metric string)

func (*Metrics) Increment

func (self *Metrics) Increment(metric string)

func (*Metrics) IncrementBy

func (self *Metrics) IncrementBy(metric string, count int)

func (*Metrics) Prefix

func (self *Metrics) Prefix(newPrefix string)

func (*Metrics) Snapshot

func (self *Metrics) Snapshot() map[string]interface{}

func (*Metrics) Timer

func (self *Metrics) Timer(metric string, value int64)

type MzConfig

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

func ReadMzConfig

func ReadMzConfig(filename string) (config *MzConfig, err error)

Read a ini like configuration file into a map

func (*MzConfig) Get

func (self *MzConfig) Get(key string, def string) string

Get a value from the config map, providing an optional default.

This is a fairly common behavior for me.

func (*MzConfig) GetFlag

func (self *MzConfig) GetFlag(key string) bool

Test for a boolean flag. Missing flags are false.

func (*MzConfig) Override

func (self *MzConfig) Override(key string, val string) string

func (*MzConfig) SetDefault

func (self *MzConfig) SetDefault(key string, val string) string

Set a value if it's not already defined

func (MzConfig) SetDefaultFlag

func (self MzConfig) SetDefaultFlag(key string, val bool) (flag bool)

Set the boolean flag if not already specified

Jump to

Keyboard shortcuts

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