log

package
v1.358.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 90

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LibraryName string
View Source
var LibraryRepository string

LibraryRepository that is passed into with -ldflags

Functions

func DeferExitHandler added in v1.9.0

func DeferExitHandler(handler func())

DeferExitHandler registers a logrus exit handler to allow cleanup activities.

func Entry

func Entry() *logrus.Entry

Entry returns the logger entry or creates one if none is present.

func GetFatalErrorDetail added in v1.197.0

func GetFatalErrorDetail() []byte

GetFatalErrorDetail retrieves the error which is currently known to the execution of a step

func IsVerbose added in v1.346.0

func IsVerbose() bool

IsVerbose returns true if DegbuLevel is enabled.

func RegisterANSHookIfConfigured added in v1.226.0

func RegisterANSHookIfConfigured(correlationID string) error

RegisterANSHookIfConfigured creates a new ANS hook for logrus if it is configured and registers it

func RegisterHook added in v1.25.0

func RegisterHook(hook logrus.Hook)

RegisterHook registers a logrus hook

func RegisterSecret added in v1.23.0

func RegisterSecret(secret string)

RegisterSecret registers a value which should be masked in every log message

func SetErrorCategory added in v1.47.0

func SetErrorCategory(category ErrorCategory)

SetErrorCategory sets the error category This can be used later by calling log.GetErrorCategory() In addition it will be used when exiting the program with log.FatalError(err, message)

func SetFatalErrorDetail added in v1.197.0

func SetFatalErrorDetail(error []byte)

SetFatalErrorDetail sets the fatal error to be stored

func SetFormatter added in v1.28.0

func SetFormatter(logFormat string)

SetFormatter specifies the log format to use for piper's output

func SetStepName

func SetStepName(stepName string)

SetStepName sets the stepName field.

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose sets the log level with respect to verbose flag.

func Writer added in v1.28.0

func Writer() io.Writer

Writer returns an io.Writer into which a tool's output can be redirected.

Types

type ANSHook added in v1.226.0

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

ANSHook is used to set the hook features for the logrus hook

func (*ANSHook) Fire added in v1.226.0

func (ansHook *ANSHook) Fire(entry *logrus.Entry) (err error)

Fire creates a new event from the logrus and sends an event to the ANS backend

func (*ANSHook) Levels added in v1.226.0

func (ansHook *ANSHook) Levels() []logrus.Level

Levels returns the supported log level of the hook.

type CollectorHook added in v1.142.0

type CollectorHook struct {
	CorrelationID string
	Messages      []Message
}

func (*CollectorHook) Fire added in v1.142.0

func (f *CollectorHook) Fire(entry *logrus.Entry) error

Fire creates a new event from the logrus and stores it in the SplunkHook object

func (*CollectorHook) Levels added in v1.142.0

func (f *CollectorHook) Levels() []logrus.Level

Levels returns the supported log level of the hook.

type ErrorCategory added in v1.47.0

type ErrorCategory int

ErrorCategory defines the category of a pipeline error

const (
	ErrorUndefined ErrorCategory = iota
	ErrorBuild
	ErrorCompliance
	ErrorConfiguration
	ErrorCustom
	ErrorInfrastructure
	ErrorService
	ErrorTest
)

Error categories which allow categorizing failures

func ErrorCategoryByString added in v1.49.0

func ErrorCategoryByString(category string) ErrorCategory

ErrorCategoryByString returns the error category based on the category text

func GetErrorCategory added in v1.47.0

func GetErrorCategory() ErrorCategory

GetErrorCategory retrieves the error category which is currently known to the execution of a step

func (ErrorCategory) String added in v1.47.0

func (e ErrorCategory) String() string

type FatalHook added in v1.25.0

type FatalHook struct {
	Path          string
	CorrelationID string
}

FatalHook provides a logrus hook which persists details about a fatal error into the file system. This is helpful in order to transfer the error details to an orchestrating CI/CD system and by that make it possible to provide better error messages to the user.

func (*FatalHook) Fire added in v1.25.0

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

Fire persists the error message of the fatal error as json file into the file system.

func (*FatalHook) Levels added in v1.25.0

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

Levels returns the supported log level of the hook.

type Message added in v1.142.0

type Message struct {
	Time    time.Time    `json:"time,omitempty"`
	Level   logrus.Level `json:"level,omitempty"`
	Message string       `json:"message,omitempty"`
	Data    interface{}  `json:"data,omitempty"`
}

type PiperLogFormatter added in v1.28.0

type PiperLogFormatter struct {
	logrus.TextFormatter
	// contains filtered or unexported fields
}

PiperLogFormatter is the custom formatter of piper

func (*PiperLogFormatter) Format added in v1.28.0

func (formatter *PiperLogFormatter) Format(entry *logrus.Entry) (bytes []byte, err error)

Format the log message

type SentryHook added in v1.28.0

type SentryHook struct {
	Hub *sentry.Hub

	Event *sentry.Event
	// contains filtered or unexported fields
}

SentryHook provides a logrus hook which enables error logging to sentry platform. This is helpful in order to provide better monitoring and alerting on errors as well as the given error details can help to find the root cause of bugs.

func NewSentryHook added in v1.28.0

func NewSentryHook(sentryDsn, correlationID string) SentryHook

NewSentryHook initializes sentry sdk with dsn and creates new hook

func (*SentryHook) Fire added in v1.28.0

func (sentryHook *SentryHook) Fire(entry *logrus.Entry) error

Fire creates a new event from the error and sends it to sentry

func (*SentryHook) Levels added in v1.28.0

func (sentryHook *SentryHook) Levels() []logrus.Level

Levels returns the supported log level of the hook.

type URLLogger added in v1.237.0

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

func NewURLLogger added in v1.237.0

func NewURLLogger(stepName string) *URLLogger

func (*URLLogger) Parse added in v1.237.0

func (cl *URLLogger) Parse(buf bytes.Buffer)

func (*URLLogger) WriteURLsLogToJSON added in v1.237.0

func (cl *URLLogger) WriteURLsLogToJSON() error

Jump to

Keyboard shortcuts

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