Documentation
¶
Overview ¶
Package loglib implements some remote logging mechanisms
Index ¶
- Constants
- Variables
- func BuildAlerters(tree ConfigTree) (destinations map[string]Alerter, err error)
- func BuildMatchers(tree ConfigTree) (matchers map[string]Matcher, err error)
- func Call(uri, username, password, name string, args ...interface{}) (interface{}, *xmlrpc.Fault, error)
- func FromGelfJSON(text []byte, m *Message) error
- func ListenGelfHTTP(port int, ch chan<- *Message) error
- func ListenGelfTCP(port int, ch chan<- *Message) error
- func ListenGelfUDP(port int, ch chan<- *Message) error
- func NewEmailSender(from, hostport, auth string) (es emailSender)
- func NewMantisSender() (ms *mantisSender)
- func NewRateLimiter(eviction time.Duration) *nextMap
- func NewTwilio(from, sid, token string) twilioClient
- func UnboxGelf(rc io.ReadCloser, m *gelf.Message) (err error)
- type Alerter
- type ConfigTree
- type ElasticSearch
- type EmailSender
- type LogLevel
- type MantisSender
- type Matcher
- type Message
- type RateLimiter
- type Rule
- type SMSSender
- type SenderProvider
- type Server
Constants ¶
const ( // EMERGENCY is the highest level EMERGENCY = LogLevel(iota) // ALERT is the alert level ALERT // CRITICAL syslog level CRITICAL // ERROR syslog level ERROR // WARNING syslog level WARNING // NOTICE syslog level NOTICE // INFO syslog level INFO // DEBUG syslog level DEBUG )
const ElasticSearchPathPrefix = "/woodchuck/gelf"
ElasticSearchPathPrefix is the path prefix storing data in ElasticSearch
Variables ¶
var LevelNames = [8]string{"EMERGENCY", "ALERT", "CRITICAL", "ERROR",
"WARNING", "NOTICE", "INFO", "DEBUG"}
LevelNames is the names of the levels
var StoreCh chan *Message
StoreCh is the channel for messages to be stored
var (
//TransportConfig is the configset for transportation settings
TransportConfig = config.NewConfigSet("transportation settings", config.ExitOnError)
)
Functions ¶
func BuildAlerters ¶
func BuildAlerters(tree ConfigTree) (destinations map[string]Alerter, err error)
BuildAlerters builds the alerters map from the config tree
func BuildMatchers ¶
func BuildMatchers(tree ConfigTree) (matchers map[string]Matcher, err error)
BuildMatchers builds the matchers from the configuration
func Call ¶
func Call(uri, username, password, name string, args ...interface{}) ( interface{}, *xmlrpc.Fault, error)
Call is an xmlrpc.Call, but without gzip and Basic Auth and strips non-xml
func FromGelfJSON ¶
FromGelfJSON reads the GELF JSON into the message
func ListenGelfHTTP ¶
ListenGelfHTTP listens on the given HTTP port for multipart/form POST requests such as curl -v -F timestamp=$(date '+%s') -F short=abraka -F host=$(hostname) -F full=dabra -F facility=proba -F level=6 http://unowebprd:12203/
func ListenGelfTCP ¶
ListenGelfTCP listen on the given TCP port for full, possibly compressed GELF messages put every message into the channel
func ListenGelfUDP ¶
ListenGelfUDP listens on the given UDP port for possibly chunked GELF messages put every complete message into the channel
func NewEmailSender ¶
func NewEmailSender(from, hostport, auth string) (es emailSender)
NewEmailSender returns a new EmailSender
func NewMantisSender ¶
func NewMantisSender() (ms *mantisSender)
NewMantisSender returns a new Mantis sender
func NewRateLimiter ¶
NewRateLimiter implements a simple time-evicted rate-limiting map
Types ¶
type Alerter ¶
type Alerter interface {
Send(*Message, SenderProvider) error
}
Alerter is a message sender interface
type ConfigTree ¶
type ConfigTree interface { // Get the value at key in the TomlTree. Key is a dot-separated path (e.g. a.b.c). Returns nil if the path does not exist in the tree. Get(key string) interface{} // Keys returns the keys of the toplevel tree. Warning: this is a costly operation. Keys() []string }
ConfigTree is an interface for configuration tree (think TOML)
type ElasticSearch ¶
ElasticSearch context
func NewElasticSearch ¶
func NewElasticSearch(urls string, ttld int) *ElasticSearch
NewElasticSearch returns a new ElasticSearch message store
func (ElasticSearch) Store ¶
func (es ElasticSearch) Store(m *Message) (*esResponse, error)
Store stores a message
type EmailSender ¶
EmailSender is the email sender interface (multiple to, a subject and a []byte body)
type MantisSender ¶
MantisSender is an interface for an issue tracker injector
type Message ¶
Message is a gelf.Message wrapper
func (*Message) MarshalJSON ¶
MarshalJSON returns the message marshaled to JSON
func (*Message) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON into the message
type RateLimiter ¶
RateLimiter is an interface for a time-evicted rate-limiting map
type Rule ¶
Rule has a name, some conditions (If) and some consequences (Then) The If Matchers chained with AND
func BuildRules ¶
func BuildRules(tree ConfigTree, matchers map[string]Matcher, alerters map[string]Alerter) (rules []Rule, err error)
BuildRules builds the rules from the config and the already compiled matchers and alerters
type SenderProvider ¶
type SenderProvider interface { GetSMSSender(string) SMSSender GetEmailSender(string) EmailSender GetMantisSender(string) MantisSender }
SenderProvider is an interface for returning the specific senders
type Server ¶
type Server struct { Rules []Rule Matchers map[string]Matcher Alerters map[string]Alerter // contains filtered or unexported fields }
Server is the server context
func LoadConfig ¶
LoadConfig loads the config read from the transports and filters TOML files
func (Server) GetEmailSender ¶
func (s Server) GetEmailSender(txt string) EmailSender
GetEmailSender returns the EmailSender, if not above rate limit
func (Server) GetMantisSender ¶
func (s Server) GetMantisSender(txt string) MantisSender
GetMantisSender returns the MantisSender, if not above rate limit
func (Server) GetSMSSender ¶
GetSMSSender returns the SMSSender, implementing rate limiting