logging

package
v0.0.0-...-560f09a Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBasicLoggerOptions = BasicLoggerOptions{
	FilePath: "",
	LogLevel: DEBUG,
	MaxSize:  15,
	MaxAge:   7,
	MaxFiles: 10,
}

DefaultBasicLoggerOptions

Default options for the BasicLogger.

Functions

This section is empty.

Types

type BasicLogger

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

BasicLogger

Generic logger that writes to the specified output file.
BasicLogger is generally used for tests and local logging
requirements.

func (*BasicLogger) Close

func (l *BasicLogger) Close() error

func (*BasicLogger) Debug

func (l *BasicLogger) Debug(args ...interface{})

func (*BasicLogger) DebugLogger

func (l *BasicLogger) DebugLogger() InternalLogger

func (*BasicLogger) Debugf

func (l *BasicLogger) Debugf(msg string, args ...interface{})

func (*BasicLogger) Error

func (l *BasicLogger) Error(args ...interface{})

func (*BasicLogger) ErrorLogger

func (l *BasicLogger) ErrorLogger() InternalLogger

func (*BasicLogger) Errorf

func (l *BasicLogger) Errorf(msg string, args ...interface{})

func (*BasicLogger) Flush

func (l *BasicLogger) Flush()

func (*BasicLogger) Info

func (l *BasicLogger) Info(args ...interface{})

func (*BasicLogger) InfoLogger

func (l *BasicLogger) InfoLogger() InternalLogger

func (*BasicLogger) Infof

func (l *BasicLogger) Infof(msg string, args ...interface{})

func (*BasicLogger) LogDebugExternalAPI

func (l *BasicLogger) LogDebugExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogDebugExternalAPI Formats the log message for an external_api API debug Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*BasicLogger) LogErrorExternalAPI

func (l *BasicLogger) LogErrorExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogErrorExternalAPI Formats the log message for an external_api API error Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*BasicLogger) LogInfoExternalAPI

func (l *BasicLogger) LogInfoExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogInfoExternalAPI Formats the log message for an external_api API info Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*BasicLogger) LogWarnExternalAPI

func (l *BasicLogger) LogWarnExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogWarnExternalAPI Formats the log message for an external_api API warning Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*BasicLogger) TailscaleDebugLogger

func (l *BasicLogger) TailscaleDebugLogger(_ string) tailscaleLogger.Logf

func (*BasicLogger) TailscaleErrorLogger

func (l *BasicLogger) TailscaleErrorLogger(_ string) tailscaleLogger.Logf

func (*BasicLogger) TailscaleInfoLogger

func (l *BasicLogger) TailscaleInfoLogger(_ string) tailscaleLogger.Logf

func (*BasicLogger) TailscaleWarnLogger

func (l *BasicLogger) TailscaleWarnLogger(_ string) tailscaleLogger.Logf

func (*BasicLogger) Warn

func (l *BasicLogger) Warn(args ...interface{})

func (*BasicLogger) WarnLogger

func (l *BasicLogger) WarnLogger() InternalLogger

func (*BasicLogger) Warnf

func (l *BasicLogger) Warnf(msg string, args ...interface{})

func (*BasicLogger) WithName

func (l *BasicLogger) WithName(name string) Logger

type BasicLoggerOptions

type BasicLoggerOptions struct {
	FilePath string
	LogLevel LogLevel
	MaxSize  int
	MaxAge   int
	MaxFiles int
}

BasicLoggerOptions

Options to configure a new BasicLogger.

Properties
  - FilePath (string): path to the log file
  - Level (string) (default - DEBUG): the log level
  - MaxSize (int) (default - 15MB): the maximum size of the log file in MB
  - MaxAge (int) (default - 7): the maximum number of days to retain old log files
  - MaxFiles (int) (default - 10): the maximum number of log files

func NewDefaultBasicLoggerOptions

func NewDefaultBasicLoggerOptions(path string) BasicLoggerOptions

NewDefaultBasicLoggerOptions

Creates a new DefaultBasicLoggerOptions setting only the FilePath attribute

type ESLogger

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

func (*ESLogger) Debug

func (l *ESLogger) Debug(args ...interface{})

func (*ESLogger) DebugLogger

func (l *ESLogger) DebugLogger() InternalLogger

func (*ESLogger) Debugf

func (l *ESLogger) Debugf(msg string, args ...interface{})

func (*ESLogger) Error

func (l *ESLogger) Error(args ...interface{})

func (*ESLogger) ErrorLogger

func (l *ESLogger) ErrorLogger() InternalLogger

func (*ESLogger) Errorf

func (l *ESLogger) Errorf(msg string, args ...interface{})

func (*ESLogger) Flush

func (l *ESLogger) Flush()

func (*ESLogger) Info

func (l *ESLogger) Info(args ...interface{})

func (*ESLogger) InfoLogger

func (l *ESLogger) InfoLogger() InternalLogger

func (*ESLogger) Infof

func (l *ESLogger) Infof(msg string, args ...interface{})

func (*ESLogger) LogDebugExternalAPI

func (l *ESLogger) LogDebugExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogDebugExternalAPI Formats the log message for an external_api API debug Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*ESLogger) LogErrorExternalAPI

func (l *ESLogger) LogErrorExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogErrorExternalAPI Formats the log message for an external_api API error Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*ESLogger) LogInfoExternalAPI

func (l *ESLogger) LogInfoExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogInfoExternalAPI Formats the log message for an external_api API info Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*ESLogger) LogWarnExternalAPI

func (l *ESLogger) LogWarnExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)

LogWarnExternalAPI Formats the log message for an external_api API warning Args:

message      - string, main message of the log
endpoint     - string, endpoint that was executed in the call
method       - string, method that was called when error was thrown
methodType   - string, HTTP method type ex: [ GET, POST, PATCH, DELETE ]
ip           - string, IP address of the function caller
statusCode   - int, status code returned by HTTP server
err          - error, error that was thrown during method execution

func (*ESLogger) TailscaleDebugLogger

func (l *ESLogger) TailscaleDebugLogger(subName string) tailscaleLogger.Logf

func (*ESLogger) TailscaleErrorLogger

func (l *ESLogger) TailscaleErrorLogger(subName string) tailscaleLogger.Logf

func (*ESLogger) TailscaleInfoLogger

func (l *ESLogger) TailscaleInfoLogger(subName string) tailscaleLogger.Logf

func (*ESLogger) TailscaleWarnLogger

func (l *ESLogger) TailscaleWarnLogger(subName string) tailscaleLogger.Logf

func (*ESLogger) Warn

func (l *ESLogger) Warn(args ...interface{})

func (*ESLogger) WarnLogger

func (l *ESLogger) WarnLogger() InternalLogger

func (*ESLogger) Warnf

func (l *ESLogger) Warnf(msg string, args ...interface{})

func (*ESLogger) WithName

func (l *ESLogger) WithName(name string) Logger

type InternalLogger

type InternalLogger interface {
	Print(...interface{})
	Println(...interface{})
	Printf(string, ...interface{})

	Fatal(...interface{})
	Fatalln(...interface{})
	Fatalf(string, ...interface{})
}

type LogLevel

type LogLevel int
const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
)

func (*LogLevel) String

func (l *LogLevel) String() string

type Logger

type Logger interface {
	Flush()

	Debug(...interface{})
	Debugf(msg string, args ...interface{})

	Info(...interface{})
	Infof(msg string, args ...interface{})

	Warn(...interface{})
	Warnf(msg string, args ...interface{})

	Error(...interface{})
	Errorf(msg string, args ...interface{})

	WithName(name string) Logger

	DebugLogger() InternalLogger
	InfoLogger() InternalLogger
	WarnLogger() InternalLogger
	ErrorLogger() InternalLogger

	TailscaleDebugLogger(subName string) tailscaleLogger.Logf
	TailscaleInfoLogger(subName string) tailscaleLogger.Logf
	TailscaleWarnLogger(subName string) tailscaleLogger.Logf
	TailscaleErrorLogger(subName string) tailscaleLogger.Logf

	LogDebugExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)
	LogInfoExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)
	LogWarnExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)
	LogErrorExternalAPI(message string, endpoint string, method string, methodType string, reqId interface{}, ip string, username string, userId string, statusCode int, err error)
}

func CreateBasicLogger

func CreateBasicLogger(opts BasicLoggerOptions) (Logger, error)

CreateBasicLogger

 Creates a new logging object with subsequent loggers
 Args:
   opts (BasicLoggerOptions): options for configuring a basic logger
 Returns:
	  (BasicLogger): newly initialized logger

func CreateESLogger

func CreateESLogger(esNodes []string, esUser string, esPassword string, esIndexName string, id string) (Logger, error)

CreateESLogger Creates a new logging object with subsequent loggers Args:

logFile   - string, path to log output file

Returns:

out       - Logger, freshly created logging object with subsequent loggers

Jump to

Keyboard shortcuts

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