juju: github.com/juju/juju/logfwd Index | Files | Directories

package logfwd

import "github.com/juju/juju/logfwd"

The logfwd package contains the tools needed to do log record forwarding in juju. The common code sits at the top level. The different forwarding targets (e.g. syslog) are provided through sub-packages.

Index

Package Files

doc.go origin.go record.go

Constants

const (
    OriginTypeUnknown OriginType = 0
    OriginTypeUser               = iota
    OriginTypeMachine
    OriginTypeUnit
)

These are the recognized origin types.

type Origin Uses

type Origin struct {
    // ControllerUUID is the ID of the Juju controller under which the
    // record originated.
    ControllerUUID string

    // ModelUUID is the ID of the Juju model under which the record
    // originated.
    ModelUUID string

    // Hostname identifies the host where the record originated.
    Hostname string

    // Type identifies the kind of thing that generated the record.
    Type OriginType

    // Name identifies the thing that generated the record.
    Name string

    // Software identifies the running software that created the record.
    Software Software
}

Origin describes what created the record.

func OriginForJuju Uses

func OriginForJuju(tag names.Tag, controller, model string, ver version.Number) (Origin, error)

OriginForJuju populates a new origin for the juju client.

func OriginForMachineAgent Uses

func OriginForMachineAgent(tag names.MachineTag, controller, model string, ver version.Number) Origin

OriginForMachineAgent populates a new origin for the agent.

func OriginForUnitAgent Uses

func OriginForUnitAgent(tag names.UnitTag, controller, model string, ver version.Number) Origin

OriginForUnitAgent populates a new origin for the agent.

func (Origin) Validate Uses

func (o Origin) Validate() error

Validate ensures that the origin is correct.

type OriginType Uses

type OriginType int

OriginType is the "enum" type for the different kinds of log record origin.

func ParseOriginType Uses

func ParseOriginType(value string) (OriginType, error)

ParseOriginType converts a string to an OriginType or fails if not able. It round-trips with String().

func (OriginType) String Uses

func (ot OriginType) String() string

String returns a string representation of the origin type.

func (OriginType) Validate Uses

func (ot OriginType) Validate() error

Validate ensures that the origin type is correct.

func (OriginType) ValidateName Uses

func (ot OriginType) ValidateName(name string) error

ValidateName ensures that the given origin name is valid within the context of the origin type.

type Record Uses

type Record struct {
    // ID identifies the record and its position in a sequence
    // of records.
    ID  int64

    // Origin describes what created the record.
    Origin Origin

    // Timestamp is when the record was created.
    Timestamp time.Time

    // Level is the basic logging level of the record.
    Level loggo.Level

    // Location describes where the record was created.
    Location SourceLocation

    // Message is the record's body. It may be empty.
    Message string
}

Record holds all the information for a single log record.

func (Record) Validate Uses

func (rec Record) Validate() error

Validate ensures that the record is correct.

type Software Uses

type Software struct {
    // PrivateEnterpriseNumber is the IANA-registered "SMI Network
    // Management Private Enterprise Code" for the software's vendor.
    //
    // See https://tools.ietf.org/html/rfc5424#section-7.2.2.
    PrivateEnterpriseNumber int

    // Name identifies the software (relative to the vendor).
    Name string

    // Version is the software's version.
    Version version.Number
}

Software describes a running application.

func (Software) Validate Uses

func (sw Software) Validate() error

Validate ensures that the software info is correct.

type SourceLocation Uses

type SourceLocation struct {
    // Module is the source "module" (e.g. package) where the record
    // originated. This is optional.
    Module string

    // Filename is the base name of the source file. This is required
    // only if Line is greater than 0.
    Filename string

    // Line is the line number in the source. It is optional. A negative
    // value means "not set". So does 0 if Filename is not set. If Line
    // is greater than 0 then Filename must be set.
    Line int
}

SourceLocation identifies the line of source code that originated a log record.

func ParseLocation Uses

func ParseLocation(module, sourceLine string) (SourceLocation, error)

ParseLocation converts the given info into a SourceLocation. The expected format is "FILENAME" or "FILENAME:LINE". If the first format is used then Line is set to -1. If provided, LINE must be a non-negative integer.

func (SourceLocation) String Uses

func (loc SourceLocation) String() string

String returns a string representation of the location.

func (SourceLocation) Validate Uses

func (loc SourceLocation) Validate() error

Validate ensures that the location is correct.

Directories

PathSynopsis
syslogThe syslog package holds the tools needed to perform log forwarding from Juju to a remote syslog (RFC 5424) host.

Package logfwd imports 8 packages (graph) and is imported by 67 packages. Updated 2019-08-23. Refresh now. Tools for package owners.