logging

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 12

Documentation

Overview

Package logging handles the logging of information to the WACE log file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int

LogLevel indicates the criticality of a message, either error, warning or debug.

const (
	// ERROR logs errors and other critical information.
	ERROR LogLevel = iota
	// WARN logs unexpected or unusual situations that should be
	// recoverable.
	WARN
	// INFO logs interesting expected events (eg: successfully loaded a model plugin)
	INFO
	// DEBUG logs everything for debugging.
	DEBUG
)

func StringToLogLevel

func StringToLogLevel(textLevel string) (LogLevel, error)

StringToLogLevel converts a string to the corresponding LogLevel value

func (LogLevel) String

func (ll LogLevel) String() string

type Logging

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

The Logging struct holds the configured logged information.

func Get

func Get() *Logging

Get returns or creates the unique log instance of logging

func (*Logging) EndTransaction

func (l *Logging) EndTransaction(transactionID string) []byte

EndTransaction returns the logging buffer for the transaction

func (*Logging) LoadLogger

func (l *Logging) LoadLogger(logPath string, logLevel LogLevel) error

LoadLogger loads the logging file and sets up everything for the logging inside the log file

func (*Logging) LoadLoggerWriter

func (l *Logging) LoadLoggerWriter(logBuffer io.Writer, logLevel LogLevel) error

LoadLoggerWriter sets up everything for the logging inside the given buffer

func (*Logging) Printf

func (l *Logging) Printf(level LogLevel, format string, v ...interface{})

Printf writes a message to the log if the given level is lower than the configured max level. Arguments are handled as in fmt.Printf.

func (*Logging) Println

func (l *Logging) Println(level LogLevel, msg string)

Println writes a message to the log if the given level is lower than the configured max level.

func (*Logging) StartTransaction

func (l *Logging) StartTransaction(transactionID string)

StartTransaction creates a new buffer to log transaction information to eventually send to the WAF.

func (*Logging) TPrintf

func (l *Logging) TPrintf(level LogLevel, transactionID, format string, v ...interface{})

TPrintf writes a level message to the log and transaction buffer. It only writes to the log if the level is lower than the configured max level. It only writes ERROR and WARN messages to the transaction buffer. Arguments are handled as in fmt.Printf.

func (*Logging) TPrintln

func (l *Logging) TPrintln(level LogLevel, transactionID, msg string)

TPrintln writes a level message to the log and transaction buffer. It only writes to the log if the level is lower than the configured max level. It only writes ERROR and WARN messages to the transaction buffer.

Jump to

Keyboard shortcuts

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