Documentation ¶
Overview ¶
package message defines the Composer interface and a handful of implementations which represent the structure for messages produced by grip.
Message Composers ¶
The Composer interface provides a common way to define messages, with two main goals:
1. Provide a common interface for representing structured and unstructured logging data regardless of logging backend or interface.
2. Provide a method for *lazy* construction of log messages so they're built *only* if a log message is over threshold.
The message package also contains many implementations of Composer which should support most logging use cases. However, any package using grip for logging may need to implement custom composer types.
The Composer implementations in the message package compose the Base type to provide some common functionality around priority setting and data collection.
The logging methods in the Journaler interface typically convert all inputs into a reasonable Composer implementations.
Error Messages ¶
The error message composers underpin the Catch<> logging messages, which allow you to log error messages but let the logging system elide logging for nil errors.
Bytes Messages ¶
The bytes types make it possible to send a byte slice as a message.
Stack Messages ¶
The Stack message Composer implementations capture a full stacktrace information during message construction, and attach a message to that trace. The string form of the message includes the package and file name and line number of the last call site, while the Raw form of the message includes the entire stack. Use with an appropriate sender to capture the desired output.
All stack message constructors take a "skip" parameter which tells how many stack frames to skip relative to the invocation of the constructor. Skip values less than or equal to 0 become 1, and are equal the call site of the constructor, use larger numbers if you're wrapping these constructors in our own infrastructure.
In general Composers are lazy, and defer work until the message is being sent; however, the stack Composers must capture the stack when they're called rather than when they're sent to produce meaningful data.
Index ¶
- Constants
- type Base
- type Composer
- func CollectAllProcesses() []Composer
- func CollectBasicGoStats() Composer
- func CollectGoStatsDeltas() Composer
- func CollectGoStatsRates() Composer
- func CollectGoStatsTotals() Composer
- func CollectProcessInfo(pid int32) Composer
- func CollectProcessInfoSelf() Composer
- func CollectProcessInfoSelfWithChildren() []Composer
- func CollectProcessInfoWithChildren(pid int32) []Composer
- func CollectSystemInfo() Composer
- func ConvertToComposer(p level.Priority, message interface{}) Composer
- func ConvertToComposerWithLevel(p level.Priority, message interface{}) Composer
- func MakeEmailMessage(e Email) Composer
- func MakeExtendedFields(f Fields) Composer
- func MakeExtendedFieldsMessage(msg string, f Fields) Composer
- func MakeFields(f Fields) Composer
- func MakeFieldsMessage(message string, f Fields) Composer
- func MakeGithubStatusMessage(context string, state GithubState, URL, description string) Composer
- func MakeGithubStatusMessageWithRepo(status GithubStatus) Composer
- func MakeGoStatsDeltas(msg string) Composer
- func MakeGoStatsRates(msg string) Composer
- func MakeGoStatsTotals(msg string) Composer
- func MakeGroupComposer(msgs ...Composer) Composer
- func MakeJIRACommentMessage(issueID, body string) Composer
- func MakeJiraMessage(issue *JiraIssue) Composer
- func MakeSimpleFields(f Fields) Composer
- func MakeSimpleFieldsMessage(msg string, f Fields) Composer
- func MakeSlackMessage(target string, msg string, attachments []SlackAttachment) Composer
- func MakeSystemInfo(message string) Composer
- func NewBytes(b []byte) Composer
- func NewBytesMessage(p level.Priority, b []byte) Composer
- func NewDefaultMessage(p level.Priority, message string) Composer
- func NewEmailMessage(l level.Priority, e Email) Composer
- func NewExtendedBytes(b []byte) Composer
- func NewExtendedBytesMessage(p level.Priority, b []byte) Composer
- func NewExtendedDefaultMessage(p level.Priority, message string) Composer
- func NewExtendedFields(p level.Priority, f Fields) Composer
- func NewExtendedFieldsMessage(p level.Priority, message string, f Fields) Composer
- func NewExtendedString(m string) Composer
- func NewFields(p level.Priority, f Fields) Composer
- func NewFieldsMessage(p level.Priority, message string, f Fields) Composer
- func NewFormatted(base string, args ...interface{}) Composer
- func NewFormattedMessage(p level.Priority, base string, args ...interface{}) Composer
- func NewGenericMessage(p level.Priority, g Generic, description string) Composer
- func NewGithubStatusMessage(p level.Priority, context string, state GithubState, URL, description string) Composer
- func NewGithubStatusMessageWithRepo(p level.Priority, status GithubStatus) Composer
- func NewGoStatsDeltas(p level.Priority, msg string) Composer
- func NewGoStatsRates(p level.Priority, msg string) Composer
- func NewGoStatsTotals(p level.Priority, msg string) Composer
- func NewGroupComposer(msgs []Composer) Composer
- func NewGroupComposerWithPriority(p level.Priority, msgs []Composer) Composer
- func NewJIRACommentMessage(p level.Priority, issueID, body string) Composer
- func NewJiraMessage(project, summary string, fields ...JiraField) Composer
- func NewLine(args ...interface{}) Composer
- func NewLineMessage(p level.Priority, args ...interface{}) Composer
- func NewProcessInfo(priority level.Priority, pid int32, message string) Composer
- func NewSimpleFields(p level.Priority, f Fields) Composer
- func NewSimpleFieldsMessage(p level.Priority, msg string, f Fields) Composer
- func NewSlackMessage(p level.Priority, target string, msg string, attachments []SlackAttachment) Composer
- func NewStack(skip int, message string) Composer
- func NewStackFormatted(skip int, message string, args ...interface{}) Composer
- func NewStackLines(skip int, messages ...interface{}) Composer
- func NewString(m string) Composer
- func NewSystemInfo(priority level.Priority, message string) Composer
- func When(cond bool, m interface{}) Composer
- func WhenMsg(cond bool, m string) Composer
- func Whenf(cond bool, m string, args ...interface{}) Composer
- func Whenln(cond bool, args ...interface{}) Composer
- func WrapStack(skip int, msg interface{}) Composer
- type Email
- type ErrorComposer
- func NewError(err error) ErrorComposer
- func NewErrorMessage(p level.Priority, err error) ErrorComposer
- func NewErrorWrap(err error, base string, args ...interface{}) ErrorComposer
- func NewErrorWrapMessage(p level.Priority, err error, base string, args ...interface{}) ErrorComposer
- func NewErrorWrappedComposer(err error, m Composer) ErrorComposer
- func NewExtendedError(err error) ErrorComposer
- func NewExtendedErrorMessage(p level.Priority, err error) ErrorComposer
- func WrapError(err error, m interface{}) ErrorComposer
- func WrapErrorf(err error, msg string, args ...interface{}) ErrorComposer
- type Fields
- type Generic
- type GithubState
- type GithubStatus
- type GoRuntimeInfo
- type GroupComposer
- func (g *GroupComposer) Add(msg Composer)
- func (g *GroupComposer) Annotate(k string, v interface{}) error
- func (g *GroupComposer) Append(msgs ...Composer)
- func (g *GroupComposer) Extend(msg []Composer)
- func (g *GroupComposer) Loggable() bool
- func (g *GroupComposer) Messages() []Composer
- func (g *GroupComposer) Priority() level.Priority
- func (g *GroupComposer) Raw() interface{}
- func (g *GroupComposer) SetPriority(l level.Priority) error
- func (g *GroupComposer) String() string
- type JIRAComment
- type JiraField
- type JiraIssue
- type ProcessInfo
- type Slack
- type SlackAttachment
- type SlackAttachmentField
- type StackFrame
- type StackTrace
- type StatCPUTimes
- type SystemInfo
Constants ¶
const ( GithubStatePending = GithubState("pending") GithubStateSuccess = GithubState("success") GithubStateError = GithubState("error") GithubStateFailure = GithubState("failure") )
The list of valid states for Github Status API requests
const FieldsMsgName = "message"
FieldsMsgName is the name of the default "message" field in the fields structure.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { Level level.Priority `bson:"level,omitempty" json:"level,omitempty" yaml:"level,omitempty"` Hostname string `bson:"hostname,omitempty" json:"hostname,omitempty" yaml:"hostname,omitempty"` Time time.Time `bson:"time,omitempty" json:"time,omitempty" yaml:"time,omitempty"` Process string `bson:"process,omitempty" json:"process,omitempty" yaml:"process,omitempty"` Pid int `bson:"pid,omitempty" json:"pid,omitempty" yaml:"pid,omitempty"` Context Fields `bson:"context,omitempty" json:"context,omitempty" yaml:"context,omitempty"` }
Base provides a simple embeddable implementation of some common aspects of a message.Composer. Additionally the Collect() method collects some simple metadata, that may be useful for some more structured logging applications.
func (*Base) Annotate ¶
Annotate makes it possible for callers and senders to add structured data to a message. This may be overridden for some implementations
func (*Base) Collect ¶
Collect records the message time. If includeExtended is true, it also includes, the process ID, process name, and hostname. Useful for logging extended metadata information.
func (*Base) IsZero ¶
IsZero returns true when Base is nil or it is non-nil and none of its fields are set.
type Composer ¶
type Composer interface { // Returns the content of the message as a string for use in // line-printing logging engines. String() string // A "raw" format of the logging output for use by some Sender // implementations that write logged items to interfaces that // accept JSON or another structured format. Raw() interface{} // Returns "true" when the message has content and should be // logged, and false otherwise. When false, the sender can // (and should!) ignore messages even if they are otherwise // above the logging threshold. Loggable() bool // Annotate makes it possible for Senders and Journalers to // add structured data to a log message. May return an error // when the key alrady exists. Annotate(string, interface{}) error // Priority returns the priority of the message. Priority() level.Priority SetPriority(level.Priority) error }
Composer defines an interface with a "String()" method that returns the message in string format. Objects that implement this interface, in combination to the Compose[*] operations, the String() method is only caled if the priority of the method is greater than the threshold priority. This makes it possible to defer building log messages (that may be somewhat expensive to generate) until it's certain that we're going to be outputting the message.
func CollectAllProcesses ¶
func CollectAllProcesses() []Composer
CollectAllProcesses returns a slice of populated ProcessInfo message.Composer interfaces for all processes currently running on a system.
func CollectBasicGoStats ¶
func CollectBasicGoStats() Composer
CollectBasicGoStats returns some very basic runtime statistics about the current go process, using runtime.MemStats and runtime.NumGoroutine.
The data reported for the runtime event metrics (e.g. mallocs, frees, gcs, and cgo calls,) are the counts since the last time metrics were collected, and are reported as rates calculated since the last time the statics were collected.
Values are cached between calls, to produce the deltas. For the best results, collect these messages on a regular interval.
Internally, this uses message.Fields message type, which means the order of the fields when serialized is not defined and applications cannot manipulate the Raw value of this composer.
The basic idea is taken from https://github.com/YoSmudge/go-stats.
func CollectGoStatsDeltas ¶
func CollectGoStatsDeltas() Composer
CollectGoStatsDeltas constructs a Composer, which is a GoRuntimeInfo internally, that contains data collected from the Go runtime about the state of memory use and garbage collection.
The data reported for the runtime event metrics (e.g. mallocs, frees, gcs, and cgo calls,) are the counts since the last time metrics were collected.
Values are cached between calls, to produce the deltas. For the best results, collect these messages on a regular interval.
func CollectGoStatsRates ¶
func CollectGoStatsRates() Composer
CollectGoStatsRates constructs a Composer, which is a GoRuntimeInfo internally, that contains data collected from the Go runtime about the state of memory use and garbage collection.
The data reported for the runtime event metrics (e.g. mallocs, frees, gcs, and cgo calls,) are the counts since the last time metrics were collected, divided by the time since the last time the metric was collected, to produce a rate, which is calculated using integer division.
For the best results, collect these messages on a regular interval.
func CollectGoStatsTotals ¶
func CollectGoStatsTotals() Composer
CollectGoStatsTotals constructs a Composer, which is a GoRuntimeInfo internally, that contains data collected from the Go runtime about the state of memory use and garbage collection.
The data reported for the runtime event metrics (e.g. mallocs, frees, gcs, and cgo calls,) are totals collected since the beginning on the runtime.
func CollectProcessInfo ¶
CollectProcessInfo returns a populated ProcessInfo message.Composer instance for the specified pid.
func CollectProcessInfoSelf ¶
func CollectProcessInfoSelf() Composer
CollectProcessInfoSelf returns a populated ProcessInfo message.Composer for the pid of the current process.
func CollectProcessInfoSelfWithChildren ¶
func CollectProcessInfoSelfWithChildren() []Composer
CollectProcessInfoSelfWithChildren returns a slice of populated ProcessInfo message.Composer instances for the current process and all children processes.
func CollectProcessInfoWithChildren ¶
CollectProcessInfoWithChildren returns a slice of populated ProcessInfo message.Composer instances for the process with the specified pid and all children processes for that process.
func CollectSystemInfo ¶
func CollectSystemInfo() Composer
CollectSystemInfo returns a populated SystemInfo object, without a message.
func ConvertToComposer ¶
ConvertToComposer can coerce unknown objects into Composer instances, as possible. This method will override the priority of composers set to it.
func ConvertToComposerWithLevel ¶
ConvertToComposerWithLevel can coerce unknown objects into Composers, but will only override the priority of Composers.
func MakeEmailMessage ¶
MakeEmailMessage creates a composer for emails without a priority set
func MakeExtendedFields ¶
MakeExtendedFields is the same as MakeFields but also collects extended logging metadata.
func MakeExtendedFieldsMessage ¶
MakeExtendedFieldsMessage is the same as MakeFieldsMessage but also collects extended logging metadata.
func MakeFields ¶
MakeFields creates a composer interface from *just* a Fields instance.
func MakeFieldsMessage ¶
MakeFieldsMessage constructs a fields Composer from a message string and Fields object, without specifying the priority of the message. This includes basic metadata.
func MakeGithubStatusMessage ¶
func MakeGithubStatusMessage(context string, state GithubState, URL, description string) Composer
MakeGithubStatusMessage creates a composer for sending payloads to the Github Status API without setting a priority
func MakeGithubStatusMessageWithRepo ¶
func MakeGithubStatusMessageWithRepo(status GithubStatus) Composer
MakeGithubStatusMessageWithRepo creates a composer for sending payloads to the Github Status API, with the repository and ref stored in the composer
func MakeGoStatsDeltas ¶
MakeGoStatsDeltas has the same semantics as CollectGoStatsDeltas, but additionally allows you to set a message string to annotate the data.
func MakeGoStatsRates ¶
MakeGoStatsRates has the same semantics as CollectGoStatsRates, but additionally allows you to set a message string to annotate the data.
func MakeGoStatsTotals ¶
MakeGoStatsTotals has the same semantics as CollectGoStatsTotals, but additionally allows you to set a message string to annotate the data.
func MakeGroupComposer ¶
MakeGroupComposer provides a variadic interface for creating a GroupComposer.
func MakeJIRACommentMessage ¶
MakeJIRACommentMessage returns a self-contained composer for posting a comment to a single JIRA issue. This composer will override the issue set in the JIRA sender. The composer will not have a priority set
func MakeJiraMessage ¶
MakeJiraMessage creates a jiraMessage instance with the given JiraIssue.
func MakeSimpleFields ¶
MakeSimpleFields returns a structured Composer that does not attach any logging metadata.
func MakeSimpleFieldsMessage ¶
MakeSimpleFieldsMessage returns a structured Composer that does not attach any logging metadata, but allows callers to specify the message (the "message" field) as a string.
func MakeSlackMessage ¶
func MakeSlackMessage(target string, msg string, attachments []SlackAttachment) Composer
MakeSlackMessage creates a composer for message to slack without a priority
func MakeSystemInfo ¶
MakeSystemInfo builds a populated SystemInfo object with the specified message.
func NewBytesMessage ¶
NewBytesMessage provides a Composer interface around a byte slice, which are always loggable unless the string is empty.
func NewDefaultMessage ¶
NewDefaultMessage provides a Composer interface around a single string, which are always loggable unless the string is empty.
func NewEmailMessage ¶
NewEmailMessage returns a composer for emails
func NewExtendedBytes ¶
NewExtendedBytes is the same as NewBytes but also collects extended logging metadata.
func NewExtendedBytesMessage ¶
NewExtendedBytesMessage is the same as NewBytesMessage but also collects extended logging metadata.
func NewExtendedDefaultMessage ¶
NewExtendedStringMessage is the same as NewDefaultMessage, but also collects and also collects extended logging metadata.
func NewExtendedFields ¶
NewExtendedFields is the same as NewFields but also collects extended logging metadata.
func NewExtendedFieldsMessage ¶
NewExtendedFieldsMessage is the same as NewFieldsMessage, but also collects extended logging metadata.
func NewExtendedString ¶
NewExtendedString is the same as NewString, but also collects extended logging metadata.
func NewFieldsMessage ¶
NewFieldsMessage creates a fully configured Composer instance that will attach basic metadata. This constructor allows you to include a string message as well as Fields object.
func NewFormatted ¶
NewFormatted returns a message.Composer roughly equivalent to an fmt.Sprintf().
func NewFormattedMessage ¶
NewFormattedMessage takes arguments as fmt.Sprintf(), and returns an object that only runs the format operation as part of the String() method.
func NewGenericMessage ¶
NewGenericMessage returns a composer for Generic messages
func NewGithubStatusMessage ¶
func NewGithubStatusMessage(p level.Priority, context string, state GithubState, URL, description string) Composer
NewGithubStatusMessage creates a composer for sending payloads to the Github Status API.
func NewGithubStatusMessageWithRepo ¶
func NewGithubStatusMessageWithRepo(p level.Priority, status GithubStatus) Composer
NewGithubStatusMessageWithRepo creates a composer for sending payloads to the Github Status API, with the repository and ref stored in the composer
func NewGoStatsDeltas ¶
NewGoStatsDeltas has the same semantics as CollectGoStatsDeltas, but additionally allows you to set a message string to annotate the data.
func NewGoStatsRates ¶
NewGoStatsRates has the same semantics as CollectGoStatsRates, but additionally allows you to set a message string to annotate the data.
func NewGoStatsTotals ¶
NewGoStatsTotals has the same semantics as CollectGoStatsTotals, but additionally allows you to set a message string and log level to annotate the data.
func NewGroupComposer ¶
NewGroupComposer returns a GroupComposer object from a slice of Composers.
func NewGroupComposerWithPriority ¶
NewGroupComposerWithPriority constructs a group composer from a collection of composers.
func NewJIRACommentMessage ¶
NewJIRACommentMessage returns a self-contained composer for posting a comment to a single JIRA issue. This composer will override the issue set in the JIRA sender
func NewJiraMessage ¶
NewJiraMessage creates and returns a fully formed jiraMessage, which implements message.Composer. project string and summary string are required, and any number of additional fields may be included. Fields with keys Reporter, Assignee, Type, and Labels will be specifically assigned to respective fields in the new jiraIssue included in the jiraMessage, (e.g. JiraIssue.Reporter, etc), and all other fields will be included in jiraIssue.Fields.
func NewLine ¶
func NewLine(args ...interface{}) Composer
NewLine returns a message Composer roughly equivalent to fmt.Sprintln().
func NewLineMessage ¶
NewLineMessage is a basic constructor for a type that, given a bunch of arguments, calls fmt.Sprintln() on the arguments passed to the constructor during the String() operation. Use in combination with Compose[*] logging methods.
func NewProcessInfo ¶
NewProcessInfo constructs a fully configured and populated Processinfo message.Composer instance for the specified process.
func NewSimpleFields ¶
NewSimpleFields returns a structured Composer that does not attach any logging metadata and allows callers to configure the messages' log level.
func NewSimpleFieldsMessage ¶
NewSimpleFieldsMessage returns a structured Composer that does not attach any logging metadata, but allows callers to specify the message (the "message" field) as well as the message's log-level.
func NewSlackMessage ¶
func NewSlackMessage(p level.Priority, target string, msg string, attachments []SlackAttachment) Composer
NewSlackMessage creates a composer for messages to slack
func NewStack ¶
NewStack builds a Composer implementation that captures the current stack trace with a single string message. Use the skip argument to skip frames if your embedding this in your own wrapper or wrappers.
func NewStackFormatted ¶
NewStackFormatted returns a composer that builds a fmt.Printf style message that also captures a stack trace. Use the skip argument to skip frames if your embedding this in your own wrapper or wrappers.
func NewStackLines ¶
NewStackLines returns a composer that builds a fmt.Println style message that also captures a stack trace. Use the skip argument to skip frames if your embedding this in your own wrapper or wrappers.
func NewSystemInfo ¶
NewSystemInfo returns a fully configured and populated SystemInfo object.
func When ¶
When returns a conditional message that is only logged if the condition is bool. Converts the second argument to a composer, if needed, using the same rules that the logging methods use.
func WhenMsg ¶
WhenMsg returns a conditional message that is only logged if the condition is bool, and creates a string message that will only log when the message content is not the empty string. Use this for a more strongly-typed conditional logging message.
func Whenf ¶
Whenf returns a conditional message that is only logged if the condition is bool, and creates a sprintf-style message, which will itself only log if the base expression is not the empty string.
type Email ¶
type Email struct { From string `bson:"from" json:"from" yaml:"from"` Recipients []string `bson:"recipients" json:"recipients" yaml:"recipients"` Subject string `bson:"subject" json:"subject" yaml:"subject"` Body string `bson:"body" json:"body" yaml:"body"` // PlainTextContents dictates the Content-Type of the email. If true, // it will text/plain; otherwise, it is text/html. This value is overridden // by the presence of a "Content-Type" header in Headers. PlainTextContents bool `bson:"is_plain_text" json:"is_plain_text" yaml:"is_plain_text"` // Headers adds additional headers to the email body, ignoring any // named "To", "From", "Subject", or "Content-Transfer-Encoding" // (which should be set with the above fields) Headers map[string][]string `bson:"headers" json:"headers" yaml:"headers"` }
Email represents the parameters of an email message
type ErrorComposer ¶
ErrorComposer defines an interface to a Composer that also includes an error.
func NewError ¶
func NewError(err error) ErrorComposer
NewError returns an ErrorComposer, like NewErrorMessage, but without the requirement to specify priority, which you may wish to specify directly.
func NewErrorMessage ¶
func NewErrorMessage(p level.Priority, err error) ErrorComposer
NewErrorMessage takes an error object and returns an ErrorComposer instance that only renders a loggable message when the error is non-nil.
These composers also implement the error interface and the pkg/errors.Causer interface and so can be passed as errors and used with existing error-wrapping mechanisms.
func NewErrorWrap ¶
func NewErrorWrap(err error, base string, args ...interface{}) ErrorComposer
NewErrorWrap produces a message.Composer that combines the functionality of an Error composer that renders a loggable error message for non-nil errors with a normal formatted message (e.g. fmt.Sprintf). These messages only log if the error is non-nil.
func NewErrorWrapMessage ¶
func NewErrorWrapMessage(p level.Priority, err error, base string, args ...interface{}) ErrorComposer
NewErrorWrapMessage produces a fully configured message.Composer that combines the functionality of an Error composer that renders a loggable error message for non-nil errors with a normal formatted message (e.g. fmt.Sprintf). These messages only log if the error is non-nil.
func NewErrorWrappedComposer ¶
func NewErrorWrappedComposer(err error, m Composer) ErrorComposer
NewErrorWrappedComposer provvides a way to construct a log message that annotates an error.
func NewExtendedError ¶
func NewExtendedError(err error) ErrorComposer
NewExtendedError is like NewError, but also collects extended logging metadata.
func NewExtendedErrorMessage ¶
func NewExtendedErrorMessage(p level.Priority, err error) ErrorComposer
NewExtendedErrorMessage is like NewErrorMessage, but also collects extended logging metadata.
func WrapError ¶
func WrapError(err error, m interface{}) ErrorComposer
WrapError wraps an error and creates a composer converting the argument into a composer in the same manner as the front end logging methods.
func WrapErrorf ¶
func WrapErrorf(err error, msg string, args ...interface{}) ErrorComposer
WrapErrorf wraps an error and creates a composer using a Sprintf-style formated composer.
type Fields ¶
type Fields map[string]interface{}
Fields is a convince type that wraps map[string]interface{} and is used for attaching structured metadata to a build request. For example:
message.Fields{"key0", <value>, "key1", <value>}
type GithubState ¶
type GithubState string
GithubState represents the 4 valid states for the Github State API in a safer way
type GithubStatus ¶
type GithubStatus struct { Owner string `bson:"owner,omitempty" json:"owner,omitempty" yaml:"owner,omitempty"` Repo string `bson:"repo,omitempty" json:"repo,omitempty" yaml:"repo,omitempty"` Ref string `bson:"ref,omitempty" json:"ref,omitempty" yaml:"ref,omitempty"` Context string `bson:"context" json:"context" yaml:"context"` State GithubState `bson:"state" json:"state" yaml:"state"` URL string `bson:"url" json:"url" yaml:"url"` Description string `bson:"description" json:"description" yaml:"description"` }
GithubStatus is a message to be posted to Github's Status API
func (*GithubStatus) Valid ¶
func (p *GithubStatus) Valid() bool
Valid returns true if the message is well formed
type GoRuntimeInfo ¶
type GoRuntimeInfo struct { HeapObjects uint64 `bson:"memory.objects.heap" json:"memory.objects.heap" yaml:"memory.objects.heap"` Alloc uint64 `bson:"memory.summary.alloc" json:"memory.summary.alloc" yaml:"memory.summary.alloc"` HeapSystem uint64 `bson:"memory.summary.system" json:"memory.summary.system" yaml:"memory.summary.system"` HeapIdle uint64 `bson:"memory.heap.idle" json:"memory.heap.idle" yaml:"memory.heap.idle"` HeapInUse uint64 `bson:"memory.heap.used" json:"memory.heap.used" yaml:"memory.heap.used"` Mallocs int64 `bson:"memory.counters.mallocs" json:"memory.counters.mallocs" yaml:"memory.counters.mallocs"` Frees int64 `bson:"memory.counters.frees" json:"memory.counters.frees" yaml:"memory.counters.frees"` GC int64 `bson:"gc.rate" json:"gc.rate" yaml:"gc.rate"` GCPause time.Duration `bson:"gc.pause.duration.last" json:"gc.pause.last" yaml:"gc.pause.last"` GCLatency time.Duration `bson:"gc.pause.duration.latency" json:"gc.pause.duration.latency" yaml:"gc.pause.duration.latency"` Goroutines int64 `bson:"goroutines.total" json:"goroutines.total" yaml:"goroutines.total"` CgoCalls int64 `bson:"cgo.calls" json:"cgo.calls" yaml:"cgo.calls"` Message string `bson:"message" json:"message" yaml:"message"` Base `json:"metadata,omitempty" bson:"metadata,omitempty" yaml:"metadata,omitempty"` // contains filtered or unexported fields }
GoRuntimeInfo provides
func (*GoRuntimeInfo) Loggable ¶
func (s *GoRuntimeInfo) Loggable() bool
Loggable returns true when the GoRuntimeInfo structure is populated. Loggable is part of the Composer interface.
func (*GoRuntimeInfo) Raw ¶
func (s *GoRuntimeInfo) Raw() interface{}
Raw is part of the Composer interface and returns the GoRuntimeInfo object itself.
func (*GoRuntimeInfo) String ¶
func (s *GoRuntimeInfo) String() string
type GroupComposer ¶
type GroupComposer struct {
// contains filtered or unexported fields
}
GroupComposer handles groups of composers as a single message, joining messages with a new line for the string format and returning a slice of interfaces for the Raw() form.
Unlike most composer types, the GroupComposer is exported, and provides the additional Messages() method to access the composer objects as a slice.
func (*GroupComposer) Add ¶
func (g *GroupComposer) Add(msg Composer)
Add supports adding messages to an existing group composer.
func (*GroupComposer) Annotate ¶
func (g *GroupComposer) Annotate(k string, v interface{}) error
Annotate calls the Annotate method of every non-nil component Composer.
func (*GroupComposer) Append ¶
func (g *GroupComposer) Append(msgs ...Composer)
Append provides a variadic alternative to the Extend method.
func (*GroupComposer) Extend ¶
func (g *GroupComposer) Extend(msg []Composer)
Extend makes it possible to add a group of messages to an existing group composer.
func (*GroupComposer) Loggable ¶
func (g *GroupComposer) Loggable() bool
Loggable returns true if at least one of the constituent Composers is loggable.
func (*GroupComposer) Messages ¶
func (g *GroupComposer) Messages() []Composer
Messages returns a the underlying collection of messages.
func (*GroupComposer) Priority ¶
func (g *GroupComposer) Priority() level.Priority
Priority returns the highest priority of the constituent Composers.
func (*GroupComposer) Raw ¶
func (g *GroupComposer) Raw() interface{}
Raw returns a slice of interfaces containing the raw form of all the constituent composers.
func (*GroupComposer) SetPriority ¶
func (g *GroupComposer) SetPriority(l level.Priority) error
SetPriority sets the priority of all constituent Composers *only* if the existing level is unset, and does not propagate an error, but will *not* unset the level of the compser and will return an error in this case.
func (*GroupComposer) String ¶
func (g *GroupComposer) String() string
String satisfies the fmt.Stringer interface, and returns a string of the string form of all constituent composers joined with a newline.
type JIRAComment ¶
type JIRAComment struct { IssueID string `bson:"issue_id,omitempty" json:"issue_id,omitempty" yaml:"issue_id,omitempty"` Body string `bson:"body" json:"body" yaml:"body"` }
JIRAComment represents a single comment to post to the given JIRA issue
type JiraField ¶
type JiraField struct { Key string Value interface{} }
JiraField is a struct composed of a key-value pair.
type JiraIssue ¶
type JiraIssue struct { IssueKey string `bson:"issue_key" json:"issue_key" yaml:"issue_key"` Project string `bson:"project" json:"project" yaml:"project"` Summary string `bson:"summary" json:"summary" yaml:"summary"` Description string `bson:"description" json:"description" yaml:"description"` Reporter string `bson:"reporter" json:"reporter" yaml:"reporter"` Assignee string `bson:"assignee" json:"assignee" yaml:"assignee"` Type string `bson:"type" json:"type" yaml:"type"` Components []string `bson:"components" json:"components" yaml:"components"` Labels []string `bson:"labels" json:"labels" yaml:"labels"` FixVersions []string `bson:"versions" json:"versions" yaml:"versions"` // ... other fields Fields map[string]interface{} `bson:"fields" json:"fields" yaml:"fields"` Callback func(string) `bson:"-" json:"-" yaml:"-"` }
JiraIssue requires project and summary to create a real jira issue. Other fields depend on permissions given to the specific project, and all fields must be legitimate custom fields defined for the project. To see whether you have the right permissions to create an issue with certain fields, check your JIRA interface on the web.
type ProcessInfo ¶
type ProcessInfo struct { Message string `json:"message" bson:"message"` Pid int32 `json:"pid" bson:"pid"` Parent int32 `json:"parentPid" bson:"parentPid"` Threads int `json:"numThreads" bson:"numThreads"` Command string `json:"command" bson:"command"` CPU StatCPUTimes `json:"cpu" bson:"cpu"` IoStat process.IOCountersStat `json:"io" bson:"io"` NetStat []net.IOCountersStat `json:"net" bson:"net"` Memory process.MemoryInfoStat `json:"mem" bson:"mem"` MemoryPlatform process.MemoryInfoExStat `json:"memExtra" bson:"memExtra"` Errors []string `json:"errors" bson:"errors"` Base `json:"metadata,omitempty" bson:"metadata,omitempty"` // contains filtered or unexported fields }
ProcessInfo holds the data for per-process statistics (e.g. cpu, memory, io). The Process info composers produce messages in this form.
func (*ProcessInfo) Loggable ¶
func (p *ProcessInfo) Loggable() bool
Loggable returns true when the Processinfo structure has been populated.
func (*ProcessInfo) Raw ¶
func (p *ProcessInfo) Raw() interface{}
Raw always returns the ProcessInfo object, however it will call the Collect method of the base operation first.
func (*ProcessInfo) String ¶
func (p *ProcessInfo) String() string
String returns a string representation of the message, lazily rendering the message, and caching it privately.
type Slack ¶
type Slack struct { Target string `bson:"target" json:"target" yaml:"target"` Msg string `bson:"msg" json:"msg" yaml:"msg"` Attachments []slack.Attachment `bson:"attachments" json:"attachments" yaml:"attachments"` }
Slack is a message to a Slack channel or user
type SlackAttachment ¶
type SlackAttachment struct { Color string `bson:"color,omitempty" json:"color,omitempty" yaml:"color,omitempty"` Fallback string `bson:"fallback,omitempty" json:"fallback,omitempty" yaml:"fallback,omitempty"` AuthorName string `bson:"author_name,omitempty" json:"author_name,omitempty" yaml:"author_name,omitempty"` AuthorIcon string `bson:"author_icon,omitempty" json:"author_icon,omitempty" yaml:"author_icon,omitempty"` Title string `bson:"title,omitempty" json:"title,omitempty" yaml:"title,omitempty"` TitleLink string `bson:"title_link,omitempty" json:"title_link,omitempty" yaml:"title_link,omitempty"` Text string `bson:"text,omitempty" json:"text,omitempty" yaml:"text,omitempty"` Fields []*SlackAttachmentField `bson:"fields,omitempty" json:"fields,omitempty" yaml:"fields,omitempty"` MarkdownIn []string `bson:"mrkdwn_in,omitempty" json:"mrkdwn_in,omitempty" yaml:"mrkdwn_in,omitempty"` }
SlackAttachment is a single attachment to a slack message. This type contains fields found in slack-go/slack.Attachment
type SlackAttachmentField ¶
type SlackAttachmentField struct { Title string `bson:"title" json:"title" yaml:"title"` Value string `bson:"value" json:"value" yaml:"value"` Short bool `bson:"short" json:"short" yaml:"short"` }
SlackAttachmentField is one of the optional fields that can be attached to a slack message. This type is the same as slack-go/slack.AttachmentField
type StackFrame ¶
type StackFrame struct { Function string `bson:"function" json:"function" yaml:"function"` File string `bson:"file" json:"file" yaml:"file"` Line int `bson:"line" json:"line" yaml:"line"` }
StackFrame captures a single item in a stack trace, and is used internally and in the StackTrace output.
func (StackFrame) String ¶
func (f StackFrame) String() string
type StackTrace ¶
type StackTrace struct { Context interface{} `bson:"context,omitempty" json:"context,omitempty" yaml:"context,omitempty"` Frames stackFrames `bson:"frames" json:"frames" yaml:"frames"` }
StackTrace structs are returned by the Raw method of the stackMessage type
func (StackTrace) String ¶
func (s StackTrace) String() string
type StatCPUTimes ¶
type StatCPUTimes struct { User int64 `json:"user" bson:"user"` System int64 `json:"system" bson:"system"` Idle int64 `json:"idle" bson:"idle"` Nice int64 `json:"nice" bson:"nice"` Iowait int64 `json:"iowait" bson:"iowait"` Irq int64 `json:"irq" bson:"irq"` Softirq int64 `json:"softirq" bson:"softirq"` Steal int64 `json:"steal" bson:"steal"` Guest int64 `json:"guest" bson:"guest"` GuestNice int64 `json:"guestNice" bson:"guestNice"` }
StatCPUTimes provides a mirror of gopsutil/cpu.TimesStat with integers rather than floats.
type SystemInfo ¶
type SystemInfo struct { Message string `json:"message" bson:"message"` CPU StatCPUTimes `json:"cpu" bson:"cpu"` CPUPercent float64 `json:"cpu_percent" bson:"cpu_percent"` NumCPU int `json:"num_cpus" bson:"num_cpus"` VMStat mem.VirtualMemoryStat `json:"vmstat" bson:"vmstat"` NetStat net.IOCountersStat `json:"netstat" bson:"netstat"` Partitions []disk.PartitionStat `json:"partitions" bson:"partitions"` Usage []disk.UsageStat `json:"usage" bson:"usage"` IOStat []disk.IOCountersStat `json:"iostat" bson:"iostat"` Errors []string `json:"errors" bson:"errors"` Base `json:"metadata,omitempty" bson:"metadata,omitempty"` // contains filtered or unexported fields }
SystemInfo is a type that implements message.Composer but also collects system-wide resource utilization statistics about memory, CPU, and network use, along with an optional message.
func (*SystemInfo) Loggable ¶
func (s *SystemInfo) Loggable() bool
Loggable returns true when the Processinfo structure has been populated.
func (*SystemInfo) Raw ¶
func (s *SystemInfo) Raw() interface{}
Raw always returns the SystemInfo object.
func (*SystemInfo) String ¶
func (s *SystemInfo) String() string
String returns a string representation of the message, lazily rendering the message, and caching it privately.