Documentation
¶
Index ¶
Constants ¶
const DefaultTemplate = "{{.Timestamp}} [{{.Namespace}}] {{.PodName}}/{{.ContainerName}}: {{.Message}}"
DefaultTemplate is the default template format
const DefaultTimestampFormat = time.RFC3339
DefaultTimestampFormat is the default format for timestamps
Variables ¶
var ColorMap = map[string]string{
"reset": "\033[0m",
"black": "\033[30m",
"red": "\033[31m",
"green": "\033[32m",
"yellow": "\033[33m",
"blue": "\033[34m",
"magenta": "\033[35m",
"cyan": "\033[36m",
"white": "\033[37m",
"boldBlack": "\033[1;30m",
"boldRed": "\033[1;31m",
"boldGreen": "\033[1;32m",
"boldYellow": "\033[1;33m",
"boldBlue": "\033[1;34m",
"boldMagenta": "\033[1;35m",
"boldCyan": "\033[1;36m",
"boldWhite": "\033[1;37m",
}
ColorMap defines ANSI color codes for colorized output
Functions ¶
This section is empty.
Types ¶
type JSONFormatter ¶
type JSONFormatter struct { // Fields to include in the JSON output IncludeTimestamp bool IncludeNamespace bool IncludePodName bool IncludeContainerName bool }
JSONFormatter formats log messages as JSON
func NewJSONFormatter ¶
func NewJSONFormatter() *JSONFormatter
NewJSONFormatter creates a new JSONFormatter with default settings
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(msg LogMessage) string
Format converts a LogMessage to a JSON string
type JSONLogEntry ¶
type JSONLogEntry struct { Timestamp string `json:"timestamp,omitempty"` Namespace string `json:"namespace,omitempty"` PodName string `json:"pod_name,omitempty"` ContainerName string `json:"container_name,omitempty"` Message string `json:"message"` }
JSONLogEntry represents a log entry in JSON format
type LogMessage ¶
type LogMessage struct { // Namespace is the kubernetes namespace of the pod Namespace string // PodName is the name of the pod PodName string // ContainerName is the name of the container within the pod ContainerName string // Timestamp is the time when the log message was created Timestamp time.Time // Message is the log content Message string // Raw contains the original bytes of the log message Raw []byte }
LogMessage represents a single log entry from a kubernetes pod/container
type TemplateFormatter ¶
type TemplateFormatter struct { // Template is the parsed template for formatting Template *template.Template }
TemplateFormatter formats log messages using Go templates
func NewTemplateFormatter ¶
func NewTemplateFormatter() (*TemplateFormatter, error)
NewTemplateFormatter creates a new TemplateFormatter with the default template
func NewTemplateFormatterWithTemplate ¶
func NewTemplateFormatterWithTemplate(templateStr string) (*TemplateFormatter, error)
NewTemplateFormatterWithTemplate creates a new TemplateFormatter with a custom template
func (*TemplateFormatter) Format ¶
func (f *TemplateFormatter) Format(msg LogMessage) string
Format converts a LogMessage to a formatted string using the template
type TextFormatter ¶
type TextFormatter struct { // ShowTimestamp controls whether to display the timestamp ShowTimestamp bool // ShowNamespace controls whether to display the namespace ShowNamespace bool // ShowPodName controls whether to display the pod name ShowPodName bool // ShowContainerName controls whether to display the container name ShowContainerName bool // TimestampFormat defines the format for timestamps TimestampFormat string // ColorOutput enables colorized output ColorOutput bool }
TextFormatter formats log messages as text
func NewTextFormatter ¶
func NewTextFormatter() *TextFormatter
NewTextFormatter creates a new TextFormatter with default settings
func (*TextFormatter) Format ¶
func (f *TextFormatter) Format(msg LogMessage) string
Format converts a LogMessage to a formatted string