Documentation ¶
Index ¶
- Constants
- func GetRequiredEnvVars() (string, error)
- func GetRequiredWriters(sys *piazza.SystemConfig, loggerIndex string) (Writer, Writer, error)
- type AuditElement
- type DaemonWriter
- type ElasticWriter
- func (w *ElasticWriter) Close() error
- func (w *ElasticWriter) CreateIndex() (bool, error)
- func (w *ElasticWriter) CreateType(mapping string) (bool, error)
- func (w *ElasticWriter) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error)
- func (w *ElasticWriter) Read(count int) ([]Message, error)
- func (w *ElasticWriter) SetID(id string) error
- func (w *ElasticWriter) SetType(typ string) error
- func (w *ElasticWriter) Write(mssg *Message, async bool) error
- type FileWriter
- type HttpWriter
- type LocalReaderWriter
- type Logger
- func (logger *Logger) Audit(actor interface{}, action interface{}, actee interface{}, text string, ...) error
- func (logger *Logger) Debug(text string, v ...interface{}) error
- func (logger *Logger) Error(text string, v ...interface{}) error
- func (logger *Logger) Fatal(text string, v ...interface{}) error
- func (logger *Logger) Info(text string, v ...interface{}) error
- func (logger *Logger) Information(text string, v ...interface{}) error
- func (logger *Logger) Metric(name string, value float64, object string, text string, v ...interface{}) error
- func (logger *Logger) Notice(text string, v ...interface{}) error
- func (logger *Logger) Warn(text string, v ...interface{}) error
- func (logger *Logger) Warning(text string, v ...interface{}) error
- type Message
- type MetricElement
- type MultiWriter
- type NilWriter
- type Reader
- type Severity
- type SourceElement
- type StderrWriter
- type StdoutWriter
- type SyslogdWriter
- type Writer
- type WriterReader
Constants ¶
const ( SyslogdNetwork = "" SyslogdRaddr = "" LoggerType = "LogData" )
const DefaultFacility = 1 // for "user-level" messages
const DefaultVersion = 1 // as per RFC 5424
Variables ¶
This section is empty.
Functions ¶
func GetRequiredEnvVars ¶
func GetRequiredWriters ¶
Types ¶
type AuditElement ¶
type AuditElement struct { Actor string `json:"actor"` Action string `json:"action"` Actee string `json:"actee"` // optional }
AuditElement represents an SDE for auditing (security-specific of just general).
func (*AuditElement) String ¶
func (ae *AuditElement) String(pen string) string
String builds and returns the RFC5424-style textual representation of an Audit SDE
type DaemonWriter ¶
type DaemonWriter struct {
// contains filtered or unexported fields
}
A DaemonWriter is a connection to a syslog server.
func Dial ¶
func Dial(network, raddr string) (*DaemonWriter, error)
Dial establishes a connection to a log daemon by connecting to address raddr on the specified network. Each write to the returned writer sends a log message. If network is empty, Dial will connect to the local syslog server.
func (*DaemonWriter) Close ¶
func (w *DaemonWriter) Close() error
Close closes a connection to the syslog daemon.
func (*DaemonWriter) Write ¶
func (w *DaemonWriter) Write(msg string) (err error)
type ElasticWriter ¶
type ElasticWriter struct { Esi elasticsearch.IIndex // contains filtered or unexported fields }
ElasticWriter implements the Writer, writing to elasticsearch
func NewElasticWriter ¶
func NewElasticWriter(esi elasticsearch.IIndex, typ string) *ElasticWriter
func (*ElasticWriter) Close ¶
func (w *ElasticWriter) Close() error
Close does nothing but satisfy an interface.
func (*ElasticWriter) CreateIndex ¶
func (w *ElasticWriter) CreateIndex() (bool, error)
func (*ElasticWriter) CreateType ¶
func (w *ElasticWriter) CreateType(mapping string) (bool, error)
func (*ElasticWriter) GetMessages ¶
func (w *ElasticWriter) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error)
func (*ElasticWriter) SetID ¶
func (w *ElasticWriter) SetID(id string) error
SetID sets the id to write to
func (*ElasticWriter) SetType ¶
func (w *ElasticWriter) SetType(typ string) error
SetType sets the type to write to
type FileWriter ¶
type FileWriter struct { FileName string // contains filtered or unexported fields }
FileWriter implements the Writer interface, writing to a given file
func (*FileWriter) Close ¶
func (w *FileWriter) Close() error
Close closes the file. The creator of the FileWriter must call this.
type HttpWriter ¶
type HttpWriter struct {
// contains filtered or unexported fields
}
HttpWriter implements Writer, by talking to the actual pz-logger service
func NewHttpWriter ¶
func NewHttpWriter(url string, apiKey string) (*HttpWriter, error)
func (*HttpWriter) Close ¶
func (w *HttpWriter) Close() error
func (*HttpWriter) GetMessages ¶
func (w *HttpWriter) GetMessages( format *piazza.JsonPagination, params *piazza.HttpQueryParams) ([]Message, int, error)
GetMessages is only implemented for HttpWriter as it is most likely the only Writer to be used for reading back data.
type LocalReaderWriter ¶
type LocalReaderWriter struct {
// contains filtered or unexported fields
}
MessageWriter implements Reader and Writer, using an array of Messages as the backing store
func (*LocalReaderWriter) Close ¶
func (w *LocalReaderWriter) Close() error
func (*LocalReaderWriter) GetMessages ¶
func (w *LocalReaderWriter) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error)
type Logger ¶
type Logger struct { MinimumSeverity Severity // minimum severity level you want to record UseSourceElement bool Async bool // contains filtered or unexported fields }
Logger is the "helper" class that can (should) be used by services to send messages. Client needs to supply the right kind of Writer.
func (*Logger) Audit ¶
func (logger *Logger) Audit(actor interface{}, action interface{}, actee interface{}, text string, v ...interface{}) error
Audit sends a log message with the audit SDE.
func (*Logger) Information ¶
Information sends a log message with severity "Informational".
func (*Logger) Metric ¶
func (logger *Logger) Metric(name string, value float64, object string, text string, v ...interface{}) error
Metric sends a log message with the metric SDE.
type Message ¶
type Message struct { Facility int `json:"facility"` Severity Severity `json:"severity"` Version int `json:"version"` TimeStamp piazza.TimeStamp `json:"timeStamp"` // see note above HostName string `json:"hostName"` Application string `json:"application"` Process string `json:"process"` MessageID string `json:"messageId"` AuditData *AuditElement `json:"auditData"` MetricData *MetricElement `json:"metricData"` SourceData *SourceElement `json:"sourceData"` Message string `json:"message"` // contains filtered or unexported fields }
Message represents all the fields of a native RFC5424 object, plus our own SDEs.
func NewMessage ¶
NewMessage returns a Message with some of the defaults filled in for you. The returned Message is not valid. To make it pass Message.Validate, you must set Severity, HostName, Application, and Process.
func (*Message) IsSecurityAudit ¶
IsSecurityAudit returns true iff the audit action is something we need to formally record as an auidtable event.
type MetricElement ¶
type MetricElement struct { Name string `json:"name"` Value float64 `json:"value"` Object string `json:"object"` }
MetricElement represents an SDE for recoridng metrics.
func (*MetricElement) String ¶
func (me *MetricElement) String(pen string) string
String builds and returns the RFC5424-style textual representation of an Metric SDE
type MultiWriter ¶
type MultiWriter struct {
// contains filtered or unexported fields
}
MultiWriter will write to N different Writers at once. When doing a Write or a Close, we call the function on all of them. If any have failed, we return the error from the first one that failed.
func NewMultiWriter ¶
func NewMultiWriter(ws []Writer) *MultiWriter
func (*MultiWriter) Close ¶
func (mw *MultiWriter) Close() error
type Reader ¶
type Reader interface { Read(count int) ([]Message, error) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error) }
Reader is an interface for reading Messages from some sort of input. count is the number of messages to read: 1 means the latest message, 2 means the two latest messages, etc. The newest message is at the end of the array.
type SourceElement ¶
type SourceElement struct { File string `json:"file"` Function string `json:"function"` Line int `json:"line"` }
SourceElement represents an SDE for tracking the message back to the source code.
func NewSourceElement ¶
func NewSourceElement(skip int) *SourceElement
func (*SourceElement) String ¶
func (se *SourceElement) String(pen string) string
String builds the text string of the SDE
type SyslogdWriter ¶
type SyslogdWriter struct {
// contains filtered or unexported fields
}
SyslogdWriter implements a Writer that writes to the syslogd system service. This will almost certainly not work on Windows, but that is okay because Piazza does not support Windows.
func (*SyslogdWriter) Close ¶
func (w *SyslogdWriter) Close() error
Close closes the underlying network connection.
type Writer ¶
type Writer interface { Write(*Message, bool) error Close() error // contains filtered or unexported methods }
Writer is an interface for writing a Message to some sort of output.