Documentation ¶
Overview ¶
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 ¶
Constants ¶
const ( OriginTypeUnknown OriginType = 0 OriginTypeUser = iota OriginTypeMachine OriginTypeUnit )
These are the recognized origin types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Origin ¶
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 ¶
OriginForJuju populates a new origin for the juju client.
func OriginForMachineAgent ¶
func OriginForMachineAgent(tag names.MachineTag, controller, model string, ver version.Number) Origin
OriginForMachineAgent populates a new origin for the agent.
func OriginForUnitAgent ¶
OriginForUnitAgent populates a new origin for the agent.
type OriginType ¶
type OriginType int
OriginType is the "enum" type for the different kinds of log record origin.
func ParseOriginType ¶
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 ¶
func (ot OriginType) String() string
String returns a string representation of the origin type.
func (OriginType) Validate ¶
func (ot OriginType) Validate() error
Validate ensures that the origin type is correct.
func (OriginType) ValidateName ¶
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 ¶
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.
type Software ¶
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.
type SourceLocation ¶
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 ¶
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 ¶
func (loc SourceLocation) String() string
String returns a string representation of the location.
func (SourceLocation) Validate ¶
func (loc SourceLocation) Validate() error
Validate ensures that the location is correct.