pz-gocommon: github.com/venicegeo/pz-gocommon/syslog Index | Files

package syslog

import "github.com/venicegeo/pz-gocommon/syslog"

Index

Package Files

DaemonWriter.go Logger.go Message.go Writers.go

Constants

const (
    SyslogdNetwork = ""
    SyslogdRaddr   = ""
    LoggerType     = "LogData"
)
const DefaultFacility = 1 // for "user-level" messages
const DefaultVersion = 1 // as per RFC 5424

func GetRequiredEnvVars Uses

func GetRequiredEnvVars() (string, error)

type AuditElement Uses

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 Uses

func (ae *AuditElement) String(pen string) string

String builds and returns the RFC5424-style textual representation of an Audit SDE

type DaemonWriter Uses

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

A DaemonWriter is a connection to a syslog server.

func Dial Uses

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 Uses

func (w *DaemonWriter) Close() error

Close closes a connection to the syslog daemon.

func (*DaemonWriter) Write Uses

func (w *DaemonWriter) Write(msg string) (err error)

type ElasticWriter Uses

type ElasticWriter struct {
    Esi elasticsearch.IIndex
    // contains filtered or unexported fields
}

ElasticWriter implements the Writer, writing to elasticsearch

func NewElasticWriter Uses

func NewElasticWriter(esi elasticsearch.IIndex, typ string) *ElasticWriter

func (*ElasticWriter) Close Uses

func (w *ElasticWriter) Close() error

Close does nothing but satisfy an interface.

func (*ElasticWriter) CreateIndex Uses

func (w *ElasticWriter) CreateIndex() (bool, error)

func (*ElasticWriter) CreateType Uses

func (w *ElasticWriter) CreateType(mapping string) (bool, error)

func (*ElasticWriter) GetMessages Uses

func (w *ElasticWriter) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error)

func (*ElasticWriter) Read Uses

func (w *ElasticWriter) Read(count int) ([]Message, error)

func (*ElasticWriter) SetID Uses

func (w *ElasticWriter) SetID(id string) error

SetID sets the id to write to

func (*ElasticWriter) SetType Uses

func (w *ElasticWriter) SetType(typ string) error

SetType sets the type to write to

func (*ElasticWriter) Write Uses

func (w *ElasticWriter) Write(mssg *Message, async bool) error

Write writes the message to the elasticsearch index, type, id

type FileWriter Uses

type FileWriter struct {
    FileName string
    // contains filtered or unexported fields
}

FileWriter implements the Writer interface, writing to a given file

func (*FileWriter) Close Uses

func (w *FileWriter) Close() error

Close closes the file. The creator of the FileWriter must call this.

func (*FileWriter) Write Uses

func (w *FileWriter) Write(mssg *Message, async bool) error

Write writes the message to the supplied file.

type HttpWriter Uses

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

HttpWriter implements Writer, by talking to the actual pz-logger service

func NewHttpWriter Uses

func NewHttpWriter(url string, apiKey string) (*HttpWriter, error)

func (*HttpWriter) Close Uses

func (w *HttpWriter) Close() error

func (*HttpWriter) GetMessages Uses

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.

func (*HttpWriter) Read Uses

func (w *HttpWriter) Read(count int) ([]Message, error)

func (*HttpWriter) Write Uses

func (w *HttpWriter) Write(mssg *Message, async bool) error

type LocalReaderWriter Uses

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 Uses

func (w *LocalReaderWriter) Close() error

func (*LocalReaderWriter) GetMessages Uses

func (w *LocalReaderWriter) GetMessages(*piazza.JsonPagination, *piazza.HttpQueryParams) ([]Message, int, error)

func (*LocalReaderWriter) Read Uses

func (w *LocalReaderWriter) Read(count int) ([]Message, error)

Read reads messages from the backing array. Will only return as many as are available; asking for too many is not an error.

func (*LocalReaderWriter) Write Uses

func (w *LocalReaderWriter) Write(mssg *Message, async bool) error

Write writes the message to the backing array

type Logger Uses

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 NewLogger Uses

func NewLogger(logWriter Writer, auditWriter Writer, application string, pen string) *Logger

func (*Logger) Audit Uses

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) Debug Uses

func (logger *Logger) Debug(text string, v ...interface{}) error

Debug sends a log message with severity "Debug".

func (*Logger) Error Uses

func (logger *Logger) Error(text string, v ...interface{}) error

Error sends a log message with severity "Error".

func (*Logger) Fatal Uses

func (logger *Logger) Fatal(text string, v ...interface{}) error

Fatal sends a log message with severity "Fatal".

func (*Logger) Info Uses

func (logger *Logger) Info(text string, v ...interface{}) error

Info is just an alternate name for Information

func (*Logger) Information Uses

func (logger *Logger) Information(text string, v ...interface{}) error

Information sends a log message with severity "Informational".

func (*Logger) Metric Uses

func (logger *Logger) Metric(name string, value float64, object string, text string, v ...interface{}) error

Metric sends a log message with the metric SDE.

func (*Logger) Notice Uses

func (logger *Logger) Notice(text string, v ...interface{}) error

Notice sends a log message with severity "Notice".

func (*Logger) Warn Uses

func (logger *Logger) Warn(text string, v ...interface{}) error

Warn is just an alternate name for Warning

func (*Logger) Warning Uses

func (logger *Logger) Warning(text string, v ...interface{}) error

Warning sends a log message with severity "Warning".

type Message Uses

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 Uses

func NewMessage(pen string) *Message

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 Uses

func (m *Message) IsSecurityAudit() bool

IsSecurityAudit returns true iff the audit action is something we need to formally record as an auidtable event.

func (*Message) String Uses

func (m *Message) String() string

String builds and returns the RFC5424-style textual representation of a Message.

func (*Message) Validate Uses

func (m *Message) Validate() error

Validate checks to see if a Message is well-formed.

type MetricElement Uses

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 Uses

func (me *MetricElement) String(pen string) string

String builds and returns the RFC5424-style textual representation of an Metric SDE

type MultiWriter Uses

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 Uses

func NewMultiWriter(ws []Writer) *MultiWriter

func (*MultiWriter) Close Uses

func (mw *MultiWriter) Close() error

func (*MultiWriter) Write Uses

func (mw *MultiWriter) Write(m *Message, async bool) (err error)

type NilWriter Uses

type NilWriter struct {
}

NilWriter doesn't do anything

func (*NilWriter) Close Uses

func (*NilWriter) Close() error

func (*NilWriter) Write Uses

func (*NilWriter) Write(*Message, bool) error

type Reader Uses

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 Severity Uses

type Severity int
const (
    Emergency     Severity = 0 // not used by Piazza
    Alert         Severity = 1 // not used by Piazza
    Fatal         Severity = 2 // called Critical in the spec
    Error         Severity = 3
    Warning       Severity = 4
    Notice        Severity = 5
    Informational Severity = 6
    Debug         Severity = 7
)

func (Severity) Value Uses

func (s Severity) Value() int

type SourceElement Uses

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 Uses

func NewSourceElement(skip int) *SourceElement

func (*SourceElement) String Uses

func (se *SourceElement) String(pen string) string

String builds the text string of the SDE

type StderrWriter Uses

type StderrWriter struct {
}

StderrWriter writes messages to STDERR

func (*StderrWriter) Close Uses

func (w *StderrWriter) Close() error

Nothing to close for this writer

func (*StderrWriter) Write Uses

func (w *StderrWriter) Write(mssg *Message, async bool) error

Writes message to STDERR

type StdoutWriter Uses

type StdoutWriter struct {
}

StdoutWriter writes messages to STDOUT

func (*StdoutWriter) Close Uses

func (w *StdoutWriter) Close() error

Nothing to close for this writer

func (*StdoutWriter) Write Uses

func (w *StdoutWriter) Write(mssg *Message, async bool) error

Writes message to STDOUT

type SyslogdWriter Uses

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 Uses

func (w *SyslogdWriter) Close() error

Close closes the underlying network connection.

func (*SyslogdWriter) Write Uses

func (w *SyslogdWriter) Write(mssg *Message, async bool) error

Write writes the message to the OS's syslogd system.

type Writer Uses

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.

func GetRequiredWriters Uses

func GetRequiredWriters(sys *piazza.SystemConfig, loggerIndex string) (Writer, Writer, error)

type WriterReader Uses

type WriterReader interface {
    Reader
    Writer
}

Package syslog imports 14 packages (graph) and is imported by 8 packages. Updated 2017-06-15. Refresh now. Tools for package owners.