util

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: MPL-2.0 Imports: 21 Imported by: 15

Documentation

Overview

Package util is a generated protocol buffer package.

from https://github.com/mozilla-services/heka/blob/dev/message/message.proto

It is generated from these files:

util/pblog.proto

It has these top-level messages:

Header
Field
Message

Index

Constants

View Source
const (
	EMERGENCY = iota // Everything is broken and on fire
	ALERT            // We're broken.
	CRITICAL         // Someone else is broken, but it's breaking us
	ERROR            // Something bad happened.
	WARNING          // Huh, that's not supposed to happen, but we can deal with it.
	NOTICE           // That was odd, but not a big deal.
	INFO             // The thing you wanted to happen happened.
	DEBUG            // debugging.
)

Message levels

View Source
const Default_Message_Severity int32 = 7

Variables

View Source
var Field_ValueType_name = map[int32]string{
	0: "STRING",
	1: "BYTES",
	2: "INTEGER",
	3: "DOUBLE",
	4: "BOOL",
}
View Source
var Field_ValueType_value = map[string]int32{
	"STRING":  0,
	"BYTES":   1,
	"INTEGER": 2,
	"DOUBLE":  3,
	"BOOL":    4,
}
View Source
var Header_HmacHashFunction_name = map[int32]string{
	0: "MD5",
	1: "SHA1",
}
View Source
var Header_HmacHashFunction_value = map[string]int32{
	"MD5":  0,
	"SHA1": 1,
}

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 RawUUID4

func RawUUID4() ([]byte, error)

func RemoteAddr

func RemoteAddr(req *http.Request) string

func ScanUUID

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

Types

type Field

type Field struct {
	Name             *string          `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	ValueType        *Field_ValueType `protobuf:"varint,2,opt,name=value_type,enum=util.Field_ValueType,def=0" json:"value_type,omitempty"`
	Representation   *string          `protobuf:"bytes,3,opt,name=representation" json:"representation,omitempty"`
	ValueString      []string         `protobuf:"bytes,4,rep,name=value_string" json:"value_string,omitempty"`
	ValueBytes       [][]byte         `protobuf:"bytes,5,rep,name=value_bytes" json:"value_bytes,omitempty"`
	ValueInteger     []int64          `protobuf:"varint,6,rep,packed,name=value_integer" json:"value_integer,omitempty"`
	ValueDouble      []float64        `protobuf:"fixed64,7,rep,packed,name=value_double" json:"value_double,omitempty"`
	ValueBool        []bool           `protobuf:"varint,8,rep,packed,name=value_bool" json:"value_bool,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

func (*Field) GetName

func (m *Field) GetName() string

func (*Field) GetRepresentation

func (m *Field) GetRepresentation() string

func (*Field) GetValueBool

func (m *Field) GetValueBool() []bool

func (*Field) GetValueBytes

func (m *Field) GetValueBytes() [][]byte

func (*Field) GetValueDouble

func (m *Field) GetValueDouble() []float64

func (*Field) GetValueInteger

func (m *Field) GetValueInteger() []int64

func (*Field) GetValueString

func (m *Field) GetValueString() []string

func (*Field) GetValueType

func (m *Field) GetValueType() Field_ValueType

func (*Field) Marshal

func (m *Field) Marshal() (data []byte, err error)

func (*Field) MarshalTo

func (m *Field) MarshalTo(data []byte) (n int, err error)

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) Reset

func (m *Field) Reset()

func (*Field) Size

func (m *Field) Size() (n int)

func (*Field) String

func (m *Field) String() string

func (*Field) Unmarshal

func (m *Field) Unmarshal(data []byte) error

type Field_ValueType

type Field_ValueType int32
const (
	Field_STRING  Field_ValueType = 0
	Field_BYTES   Field_ValueType = 1
	Field_INTEGER Field_ValueType = 2
	Field_DOUBLE  Field_ValueType = 3
	Field_BOOL    Field_ValueType = 4
)
const Default_Field_ValueType Field_ValueType = Field_STRING

func (Field_ValueType) Enum

func (x Field_ValueType) Enum() *Field_ValueType

func (Field_ValueType) String

func (x Field_ValueType) String() string

func (*Field_ValueType) UnmarshalJSON

func (x *Field_ValueType) UnmarshalJSON(data []byte) error

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 Header struct {
	MessageLength    *uint32                  `protobuf:"varint,1,req,name=message_length" json:"message_length,omitempty"`
	HmacHashFunction *Header_HmacHashFunction `protobuf:"varint,3,opt,name=hmac_hash_function,enum=util.Header_HmacHashFunction,def=0" json:"hmac_hash_function,omitempty"`
	HmacSigner       *string                  `protobuf:"bytes,4,opt,name=hmac_signer" json:"hmac_signer,omitempty"`
	HmacKeyVersion   *uint32                  `protobuf:"varint,5,opt,name=hmac_key_version" json:"hmac_key_version,omitempty"`
	Hmac             []byte                   `protobuf:"bytes,6,opt,name=hmac" json:"hmac,omitempty"`
	XXX_unrecognized []byte                   `json:"-"`
}

func (*Header) GetHmac

func (m *Header) GetHmac() []byte

func (*Header) GetHmacHashFunction

func (m *Header) GetHmacHashFunction() Header_HmacHashFunction

func (*Header) GetHmacKeyVersion

func (m *Header) GetHmacKeyVersion() uint32

func (*Header) GetHmacSigner

func (m *Header) GetHmacSigner() string

func (*Header) GetMessageLength

func (m *Header) GetMessageLength() uint32

func (*Header) Marshal

func (m *Header) Marshal() (data []byte, err error)

func (*Header) MarshalTo

func (m *Header) MarshalTo(data []byte) (n int, err error)

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) Reset

func (m *Header) Reset()

func (*Header) Size

func (m *Header) Size() (n int)

func (*Header) String

func (m *Header) String() string

func (*Header) Unmarshal

func (m *Header) Unmarshal(data []byte) error

type Header_HmacHashFunction

type Header_HmacHashFunction int32
const (
	Header_MD5  Header_HmacHashFunction = 0
	Header_SHA1 Header_HmacHashFunction = 1
)
const Default_Header_HmacHashFunction Header_HmacHashFunction = Header_MD5

func (Header_HmacHashFunction) Enum

func (Header_HmacHashFunction) String

func (x Header_HmacHashFunction) String() string

func (*Header_HmacHashFunction) UnmarshalJSON

func (x *Header_HmacHashFunction) UnmarshalJSON(data []byte) error

type JsMap

type JsMap map[string]interface{}

type Log

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

func NewLogger

func NewLogger(conf *MzConfig) *Log

Create a new Stdout logging interface.

func (*Log) Alert

func (r *Log) Alert(mtype, msg string, fields Fields) (err error)

func (*Log) Critical

func (r *Log) Critical(mtype, msg string, fields Fields) (err error)

func (*Log) Debug

func (r *Log) Debug(mtype, msg string, fields Fields) (err error)

func (*Log) Emergency

func (r *Log) Emergency(mtype, msg string, fields Fields) (err error)

func (*Log) Error

func (r *Log) Error(mtype, msg string, fields Fields) (err error)

func (*Log) Info

func (r *Log) Info(mtype, msg string, fields Fields) (err error)

func (*Log) Log

func (r *Log) 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 (*Log) Notice

func (r *Log) Notice(mtype, msg string, fields Fields) (err error)

func (*Log) Warn

func (r *Log) Warn(mtype, msg string, fields Fields) (err error)

type Logger

type Logger interface {
	Log(level int32, mtype, payload string, field Fields) error
	Info(mtype, payload string, field Fields) error
	Debug(mtype, payload string, field Fields) error
	Notice(mtype, payload string, field Fields) error
	Warn(mtype, payload string, field Fields) error
	Error(mtype, payload string, field Fields) error
	Critical(mtype, payload string, field Fields) error
	Alert(mtype, payload string, field Fields) error
}

===

type Message

type Message struct {
	Uuid             []byte   `protobuf:"bytes,1,req,name=uuid" json:"uuid,omitempty"`
	Timestamp        *int64   `protobuf:"varint,2,req,name=timestamp" json:"timestamp,omitempty"`
	Type             *string  `protobuf:"bytes,3,opt,name=type" json:"type,omitempty"`
	Logger           *string  `protobuf:"bytes,4,opt,name=logger" json:"logger,omitempty"`
	Severity         *int32   `protobuf:"varint,5,opt,name=severity,def=7" json:"severity,omitempty"`
	Payload          *string  `protobuf:"bytes,6,opt,name=payload" json:"payload,omitempty"`
	EnvVersion       *string  `protobuf:"bytes,7,opt,name=env_version" json:"env_version,omitempty"`
	Pid              *int32   `protobuf:"varint,8,opt,name=pid" json:"pid,omitempty"`
	Hostname         *string  `protobuf:"bytes,9,opt,name=hostname" json:"hostname,omitempty"`
	Fields           []*Field `protobuf:"bytes,10,rep,name=fields" json:"fields,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*Message) GetEnvVersion

func (m *Message) GetEnvVersion() string

func (*Message) GetFields

func (m *Message) GetFields() []*Field

func (*Message) GetHostname

func (m *Message) GetHostname() string

func (*Message) GetLogger

func (m *Message) GetLogger() string

func (*Message) GetPayload

func (m *Message) GetPayload() string

func (*Message) GetPid

func (m *Message) GetPid() int32

func (*Message) GetSeverity

func (m *Message) GetSeverity() int32

func (*Message) GetTimestamp

func (m *Message) GetTimestamp() int64

func (*Message) GetType

func (m *Message) GetType() string

func (*Message) GetUuid

func (m *Message) GetUuid() []byte

func (*Message) Marshal

func (m *Message) Marshal() (data []byte, err error)

func (*Message) MarshalTo

func (m *Message) MarshalTo(data []byte) (n int, err error)

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) Size

func (m *Message) Size() (n int)

func (*Message) String

func (m *Message) String() string

func (*Message) Unmarshal

func (m *Message) Unmarshal(data []byte) error

type Metric

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

func NewMetrics

func NewMetrics(prefix string, logger Logger, config *MzConfig) *Metric

func (*Metric) Decrement

func (self *Metric) Decrement(metric string)

func (*Metric) Increment

func (self *Metric) Increment(metric string)

func (*Metric) IncrementBy

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

func (*Metric) Prefix

func (self *Metric) Prefix(newPrefix string)

func (*Metric) Snapshot

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

func (*Metric) Timer

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

type Metrics

type Metrics interface {
	Increment(string)
	IncrementBy(string, int)
	Decrement(string)
	Timer(string, int64)
	Snapshot() map[string]interface{}
}

type MzConfig

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

func NewMzConfig

func NewMzConfig() *MzConfig

Used by testing mostly

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

type TestLog

type TestLog struct {
	T   *testing.T
	Out string
}

func (*TestLog) Alert

func (r *TestLog) Alert(mtype, msg string, fields Fields) error

func (*TestLog) Critical

func (r *TestLog) Critical(mtype, msg string, fields Fields) error

func (*TestLog) Debug

func (r *TestLog) Debug(mtype, msg string, fields Fields) error

func (*TestLog) Emergency

func (r *TestLog) Emergency(mtype, msg string, fields Fields) error

func (*TestLog) Error

func (r *TestLog) Error(mtype, msg string, fields Fields) error

func (*TestLog) Info

func (r *TestLog) Info(mtype, msg string, fields Fields) error

func (*TestLog) Log

func (r *TestLog) Log(level int32, mtype, payload string, fields Fields) error

func (*TestLog) Notice

func (r *TestLog) Notice(mtype, msg string, fields Fields) error

func (*TestLog) Warn

func (r *TestLog) Warn(mtype, msg string, fields Fields) error

type TestMetric

type TestMetric struct{}

func NewTestMetric

func NewTestMetric(prefix string, logger Logger, config *MzConfig) *TestMetric

func (*TestMetric) Decrement

func (r *TestMetric) Decrement(string)

func (*TestMetric) Increment

func (r *TestMetric) Increment(string)

func (*TestMetric) IncrementBy

func (r *TestMetric) IncrementBy(string, int)

func (*TestMetric) Prefix

func (r *TestMetric) Prefix(string)

func (*TestMetric) Snapshot

func (r *TestMetric) Snapshot() (m map[string]interface{})

func (*TestMetric) Timer

func (r *TestMetric) Timer(string, int64)

Jump to

Keyboard shortcuts

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