Documentation
¶
Overview ¶
Package ssmlog is used to initialize ssm functional logger
Package logger is used to initialize the logger(main logger and event logger). This package should be imported once, usually from main, then call GetLogger.
Package log is used to initialize the logger(main logger and event logger). This package should be imported once, usually from main, then call GetLogger.
Package log is used to initialize the logger. This package should be imported once, usually from main, then call GetLogger.
Package log is used to initialize the logger. This package should be imported once.
Index ¶
- Constants
- Variables
- func DefaultConfig() []byte
- func DefaultLogger() log.T
- func GetLogConfigBytes() []byte
- func GetLogger(log log.T, seelogConfig string) (logger seelog.LoggerInterface)
- func LoadLog(defaultLogDir string, logFile string, debugStatus string) []byte
- func NewSilentLogger() log.T
- func PrintCWConfig(jsonConfig string, log log.T) string
- func WriteLastLineFile(eventCounter *EventCounter) error
- type ContextFormatFilter
- type DelegateLogger
- type EventCounter
- type EventLog
- type FormatFilter
- type Wrapper
- func (w *Wrapper) Close()
- func (w *Wrapper) Closed() bool
- func (w *Wrapper) Critical(v ...interface{}) error
- func (w *Wrapper) Criticalf(format string, params ...interface{}) error
- func (w *Wrapper) Debug(v ...interface{})
- func (w *Wrapper) Debugf(format string, params ...interface{})
- func (w *Wrapper) Error(v ...interface{}) error
- func (w *Wrapper) Errorf(format string, params ...interface{}) error
- func (w *Wrapper) Flush()
- func (w *Wrapper) Info(v ...interface{})
- func (w *Wrapper) Infof(format string, params ...interface{})
- func (w *Wrapper) Log(i ...interface{})
- func (w *Wrapper) ReplaceDelegate(newLogger log.BasicT)
- func (w *Wrapper) Trace(v ...interface{})
- func (w *Wrapper) Tracef(format string, params ...interface{})
- func (w *Wrapper) Warn(v ...interface{}) error
- func (w *Wrapper) Warnf(format string, params ...interface{}) error
- func (w *Wrapper) WithContext(context ...string) (contextLogger log.T)
- func (w *Wrapper) WriteEvent(eventType string, agentVersion string, event string)
Constants ¶
const ( AmazonAgentStartEvent = "amazon-ssm-agent.start" // Amazon core agent start event AmazonAgentWorkerStartEvent = "ssm-agent-worker.start" // Amazon agent worker start event AmazonAgentInProcExecuterStartEvent = "ssm-agent-inproc-executer.start" // Amazon agent inproc executer start event SchemaVersionHeader = "SchemaVersion=" // Message types for the event log chunks created AgentTelemetryMessage = "agent_telemetry" // AgentTelemetryMessage represents message type for number Legacy Agent/Agent Reboot AgentUpdateResultMessage = "agent_update_result" // AgentUpdateResultMessage represents message type for number Agent update result BytePatternLen = 9 // BytePatternLen represents length of last read byte section in footer of audit file. Considered the audit file max file size to be 999.99MB VersionRegexPattern = "^\\d+(\\.\\d+){3}$" // pattern to filter out invalid versions )
const ( LogFile = "amazon-ssm-agent.log" ErrorFile = "errors.log" EventLogFile = "amazon-ssm-agent-audit" )
Variables ¶
var (
AuditFolderName = "audits"
)
var (
DefaultLogDir = "/var/log/amazon/ssm"
)
var DefaultSeelogConfigFilePath = appconfig.SeelogFilePath
DefaultSeelogConfigFilePath specifies the default seelog location The underlying logger is based of https://github.com/cihub/seelog See Seelog documentation to customize the logger
var PkgMutex = new(sync.RWMutex)
Functions ¶
func DefaultConfig ¶
func DefaultConfig() []byte
func DefaultLogger ¶
func GetLogConfigBytes ¶
func GetLogConfigBytes() []byte
func GetLogger ¶
func GetLogger(log log.T, seelogConfig string) (logger seelog.LoggerInterface)
GetLogger creates a new logger with the provided config and returns it
func NewSilentLogger ¶
NewSilentLogger is a logger that discards messages sent to it. Use this in situations where a function requires a log.T but messages the function sends to it need not be visible to users. contributed by github user chrisnovakovic
func PrintCWConfig ¶
PrintCWConfig checks if the config file has credentials and returns a string with the credentials removed, for printing
func WriteLastLineFile ¶
func WriteLastLineFile(eventCounter *EventCounter) error
WriteLastLineFile updates the file name with the Audit success status. This should be locked by the caller if called by multiple threads.
Types ¶
type ContextFormatFilter ¶
type ContextFormatFilter struct {
Context []string
}
ContextFormatFilter is a filter that can add a context to the parameters of a log message.
func (ContextFormatFilter) Filter ¶
func (f ContextFormatFilter) Filter(params ...interface{}) (newParams []interface{})
Filter adds the context at the beginning of the parameter slice.
func (ContextFormatFilter) Filterf ¶
func (f ContextFormatFilter) Filterf(format string, params ...interface{}) (newFormat string, newParams []interface{})
Filterf adds the context in from of the format string.
type DelegateLogger ¶
DelegateLogger holds the base logger for logging
type EventCounter ¶
type EventCounter struct { AuditFileName string // audit file name AuditDate string // Can be used later. Date to which the audit file belongs to. CountMap map[string]int // count of events found in audit log SchemaVersion string // schema version from audit file AgentVersion string // denotes agent version found in the audit log LastReadTime string // denotes last read time stamp from file LastReadByte int // denotes last read byte from file IsFirstChunk bool // denotes first chunk taken from file EventChunkType string // denotes message type used to send to MGS }
EventCounter contains the audit count, file name and the audit date to be sent to MGS
func GetEventCounter ¶
func GetEventCounter() ([]*EventCounter, error)
GetEventCounter returns the count of the audits in the previous days logs. Returns empty list when an exception is thrown by file handlers
type EventLog ¶
type EventLog struct {
// contains filtered or unexported fields
}
Creates events with the appropriate file parameters passed to this instance
func GetEventLog ¶
GetEventLog returns the Event log instance and is called by the SSM Logger during app startup
func (*EventLog) GetAuditFileName ¶
GetAuditFileName will return the audit file name without the date pattern
func (*EventLog) GetAuditFilePath ¶
GetAuditFilePath will return the audit file path
func (*EventLog) GetFileSystem ¶
func (e *EventLog) GetFileSystem() filesystem.IFileSystem
GetAuditFilePath will return the file system instance
func (*EventLog) GetTodayAuditFileName ¶
GetTodayAuditFileName will return the audit file name of currently used one
type FormatFilter ¶
type FormatFilter interface { // Filter modifies parameters that will be passed to log.Debug, log.Info, etc. Filter(params ...interface{}) (newParams []interface{}) // Filter modifies format and/or parameter strings that will be passed to log.Debugf, log.Infof, etc. Filterf(format string, params ...interface{}) (newFormat string, newParams []interface{}) }
FormatFilter can modify the format and or parameters to be passed to a logger.
type Wrapper ¶
type Wrapper struct { Format FormatFilter M *sync.RWMutex Delegate *DelegateLogger EventLogger *EventLog }
Wrapper is a logger that can modify the format of a log message before delegating to another logger.
func (*Wrapper) Close ¶
func (w *Wrapper) Close()
Close flushes all the messages in the logger and closes it. It cannot be used after this operation.
func (*Wrapper) Critical ¶
Critical formats message using the default formats for its operands and writes to log with level = Critical
func (*Wrapper) Criticalf ¶
Criticalf formats message according to format specifier and writes to log with level = Critical.
func (*Wrapper) Debug ¶
func (w *Wrapper) Debug(v ...interface{})
Debug formats message using the default formats for its operands and writes to log with level = Debug
func (*Wrapper) Debugf ¶
Debugf formats message according to format specifier and writes to log with level = Debug.
func (*Wrapper) Error ¶
Error formats message using the default formats for its operands and writes to log with level = Error
func (*Wrapper) Errorf ¶
Errorf formats message according to format specifier and writes to log with level = Error.
func (*Wrapper) Info ¶
func (w *Wrapper) Info(v ...interface{})
Info formats message using the default formats for its operands and writes to log with level = Info
func (*Wrapper) Infof ¶
Infof formats message according to format specifier and writes to log with level = Info.
func (*Wrapper) ReplaceDelegate ¶
ReplaceDelegate replaces the delegate logger with a new logger
func (*Wrapper) Trace ¶
func (w *Wrapper) Trace(v ...interface{})
Trace formats message using the default formats for its operands and writes to log with level = Trace
func (*Wrapper) Tracef ¶
Tracef formats message according to format specifier and writes to log with level = Trace.
func (*Wrapper) Warn ¶
Warn formats message using the default formats for its operands and writes to log with level = Warn
func (*Wrapper) Warnf ¶
Warnf formats message according to format specifier and writes to log with level = Warn.
func (*Wrapper) WithContext ¶
WithContext creates a wrapper logger with context