agentlog

package
v0.0.0-...-a2e9de6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomLogInit

func CustomLogInit(level logrus.Level) *logrus.Logger

CustomLogInit - allow pillar services and containers to use customized logging

func DiscardBootReason

func DiscardBootReason(log *base.LogObject)

DiscardBootReason removes the BootReason file

func DiscardRebootImage

func DiscardRebootImage(log *base.LogObject)

DiscardRebootImage : Discard the last reboot-image file

func DiscardRebootReason

func DiscardRebootReason(log *base.LogObject)

DiscardRebootReason removes any reason and stack from /persist/

func DumpAllStacks

func DumpAllStacks(log *base.LogObject, agentName string)

DumpAllStacks writes to file but does not log

func EveCurrentPartition

func EveCurrentPartition() string

EveCurrentPartition returns the current EVE image partition

func EveVersion

func EveVersion() string

EveVersion returns the version of the current image

func GetBootReason

func GetBootReason(log *base.LogObject) (types.BootReason, time.Time)

GetBootReason returns the BootReason enum, which is stored as a string in /persist, together with its timestamp

func GetLogLevel

func GetLogLevel(log *base.LogObject, sub pubsub.Subscription, agentName string) (string, bool)

Returns (value, ok)

func GetLogLevelNoDefault

func GetLogLevelNoDefault(log *base.LogObject, sub pubsub.Subscription, agentName string) (string, bool)

func GetMyStack

func GetMyStack() string

GetMyStack is used to log stack traces at certain call sites Excludes ourselves

func GetRebootImage

func GetRebootImage(log *base.LogObject) string

GetRebootImage : Image from which the reboot happened

func GetRebootReason

func GetRebootReason(log *base.LogObject) (string, time.Time, string)

GetRebootReason returns the RebootReason string together with its timestamp plus the reboot stack. We limit the size we read to 16k for the RebootReason and to 512k for the stack, because in case of a kernel crash, the stack file contains the whole dmesg, which kernel buffer is limited to some reasonable value below 512k.

func GetRemoteLogLevel

func GetRemoteLogLevel(log *base.LogObject, sub pubsub.Subscription, agentName string) (string, bool)

Returns (value, ok)

func GetRemoteLogLevelNoDefault

func GetRemoteLogLevelNoDefault(log *base.LogObject, sub pubsub.Subscription, agentName string) (string, bool)

func HandleGlobalConfig

func HandleGlobalConfig(log *base.LogObject, sub pubsub.Subscription, agentName string,
	debugOverride bool, logger *logrus.Logger) *types.ConfigItemValueMap

HandleGlobalConfig updates the LogLevel setting in the passed in logger based on GlobalConfig and debugOverride

func Init

func Init(agentName string) (*logrus.Logger, *base.LogObject)

Init provides both a logger and a logObject

func LogLevel

func LogLevel(gc *types.ConfigItemValueMap, agentName string) string

func PrintStacks

func PrintStacks(log *base.LogObject)

PrintStacks - for newlogd log init

func RebootReason

func RebootReason(reason string, bootReason types.BootReason, agentName string,
	agentPid int, normal bool)

RebootReason writes a reason string in /persist/reboot-reason, including agentName and date It also appends to /persist/log/reboot-reason.log If the bootReasonFile is not present it will write the bootReason enum there as a string. That ensures that if we have a e.g., a log.Fatal followed by watchdog we retain the fatal. NOTE: can not use log here since we are called from a log hook!

func RebootStack

func RebootStack(log *base.LogObject, stacks string, agentName string, agentPid int)

RebootStack writes stack in /persist/reboot-stack and appends to /persist/log/reboot-stack.log XXX remove latter? Can grow unbounded.

Types

type FatalHook

type FatalHook struct {
	// contains filtered or unexported fields
}

FatalHook is used make sure we save the fatal and panic strings to a file

func (*FatalHook) Fire

func (hook *FatalHook) Fire(entry *logrus.Entry) error

Fire saves the reason for the logrus.Fatal or logrus.Panic

func (*FatalHook) Levels

func (hook *FatalHook) Levels() []logrus.Level

Levels installs the FatalHook for Fatal and Panic levels

type Loginfo

type Loginfo struct {
	Level         string `json:"level"`
	Time          string `json:"time"` // RFC3339 with Nanoseconds
	Msg           string `json:"msg"`
	Pid           int    `json:"pid"`
	Function      string `json:"func"`
	Filename      string `json:"file"`
	Source        string `json:"source"`
	Appuuid       string `json:"appuuid"`
	Containername string `json:"containername"`
	Eventtime     string `json:"eventtime"`
}

Extend this structure with optional specific tags from log.WithFields

func ParseLoginfo

func ParseLoginfo(line string) (Loginfo, bool)

Returns loginfo, ok

type MemAllocationSite

type MemAllocationSite struct {
	InUseBytes   int64
	InUseObjects int64
	AllocBytes   int64
	AllocObjects int64
	PrintedStack string
}

MemAllocationSite is the return value of GetMemProfile

func GetMemAllocationSites

func GetMemAllocationSites(reportZeroInUse bool) (int, []MemAllocationSite)

GetMemAllocationSites returns the non-zero allocation sites in the form of an array of strings; each string is for one allocation call site. If reportZeroInUse is set it also reports with zero InUse.

type SkipCallerHook

type SkipCallerHook struct {
}

SkipCallerHook is used to skip to the "base" package entry in the stack

func (*SkipCallerHook) Fire

func (hook *SkipCallerHook) Fire(entry *logrus.Entry) error

Fire does the skipping

func (*SkipCallerHook) Levels

func (hook *SkipCallerHook) Levels() []logrus.Level

Levels installs the SkipCallerHook for all levels

type SourceHook

type SourceHook struct {
	// contains filtered or unexported fields
}

SourceHook is used to add source and pid if not already set

func (*SourceHook) Fire

func (hook *SourceHook) Fire(entry *logrus.Entry) error

Fire adds source and pid if not already set

func (*SourceHook) Levels

func (hook *SourceHook) Levels() []logrus.Level

Levels installs the SourceHook for all levels

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL