Documentation
¶
Overview ¶
Package logentry defines the log entry model used for centralized log collection.
Index ¶
Constants ¶
const NATSSubjectPrefix = "sys.log"
NATSSubjectPrefix is the base subject for log publishing. Full subject: sys.log.{service}
const NATSSubjectWildcard = "sys.log.>"
NATSSubjectWildcard matches all service log subjects.
Variables ¶
This section is empty.
Functions ¶
func NATSSubject ¶
NATSSubject returns the NATS subject for a given service name.
Types ¶
type LogEntry ¶
type LogEntry struct {
ID string `json:"id"` // ULID for time-ordered keys
Timestamp int64 `json:"timestamp"` // Unix millis
Service string `json:"service"` // e.g. "admin_server", "queue_server"
Level string `json:"level"` // "debug","info","warn","error","fatal"
Message string `json:"message"`
Component string `json:"component"` // sub-component within service
Hostname string `json:"hostname,omitempty"` // OS hostname of the publishing node
Fields map[string]interface{} `json:"fields,omitempty"` // structured fields from the log call site
}
LogEntry represents a single log message published by a service.
func NewLogEntry ¶
NewLogEntry creates a new LogEntry with a ULID and current timestamp.
func NewLogEntryWithFields ¶
func NewLogEntryWithFields(service, level, message, component string, fields map[string]interface{}) *LogEntry
NewLogEntryWithFields creates a new LogEntry with structured fields attached. A nil or empty fields map is omitted from the serialized entry.