logging

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, subsystem LogSubsystem, msg string, additionalFields map[string]interface{})

Debug logs a debug message with additional fields for a specific subsystem.

func Error

func Error(ctx context.Context, subsystem LogSubsystem, msg string, additionalFields map[string]interface{})

Error logs an error message with additional fields for a specific subsystem.

func Info

func Info(ctx context.Context, subsystem LogSubsystem, msg string, additionalFields map[string]interface{})

Info logs an info message with additional fields for a specific subsystem.

func MaskSensitiveData

func MaskSensitiveData(ctx context.Context, subsystem LogSubsystem, expressions []*regexp.Regexp, strings []string) context.Context

MaskSensitiveData masks sensitive data in logs based on regex patterns or strings for a specific subsystem.

func NewSubsystemLogger

func NewSubsystemLogger(ctx context.Context, subsystem LogSubsystem, level hclog.Level) context.Context

NewSubsystemLogger creates a new logger for a specific subsystem with the provided log level.

func OmitLogs

func OmitLogs(ctx context.Context, subsystem LogSubsystem, keys []string, expressions []*regexp.Regexp, strings []string) context.Context

OmitLogs omits logs containing specified keys or matching certain message patterns for a specific subsystem.

func SetLogField

func SetLogField(ctx context.Context, subsystem LogSubsystem, key string, value interface{}) context.Context

SetLogField adds a field to all logs emitted from the provided context for a specific subsystem.

func Warn

func Warn(ctx context.Context, subsystem LogSubsystem, msg string, additionalFields map[string]interface{})

Warn logs a warning message with additional fields for a specific subsystem.

Types

type ConsoleLogger

type ConsoleLogger struct {
	Diagnostics diag.Diagnostics
}

ConsoleLogger provides an implementation of the DiagnosticLogger interface. It logs messages to StdOut and creates diagnostics for errors and warnings.

func (*ConsoleLogger) Error

func (l *ConsoleLogger) Error(summary string, detail string, attributePath ...interface{})

Error logs an error message and creates a diagnostic with Error severity.

func (*ConsoleLogger) Errorf

func (l *ConsoleLogger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message and creates a diagnostic with Error severity.

func (*ConsoleLogger) Info

func (l *ConsoleLogger) Info(message string)

Info logs an informational message without creating a diagnostic.

func (*ConsoleLogger) Infof

func (l *ConsoleLogger) Infof(format string, args ...interface{})

Infof logs a formatted informational message without creating a diagnostic.

func (*ConsoleLogger) Warn

func (l *ConsoleLogger) Warn(summary string, detail string, attributePath ...interface{})

Warn logs a warning message and creates a diagnostic with Warning severity.

func (*ConsoleLogger) Warnf

func (l *ConsoleLogger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message and creates a diagnostic with Warning severity.

type DiagnosticLogger

type DiagnosticLogger interface {
	// Error logs an error message and creates a diagnostic with Error severity.
	Error(summary string, detail string, attributePath ...interface{})

	// Errorf logs a formatted error message and creates a diagnostic with Error severity.
	Errorf(format string, args ...interface{})

	// Warn logs a warning message and creates a diagnostic with Warning severity.
	Warn(summary string, detail string, attributePath ...interface{})

	// Warnf logs a formatted warning message and creates a diagnostic with Warning severity.
	Warnf(format string, args ...interface{})
}

DiagnosticLogger is an interface for logging messages that can create diagnostics for errors and warnings.

type LogSubsystem

type LogSubsystem string

LogSubsystem identifies different subsystems in your Terraform provider.

const (
	SubsystemDelete     LogSubsystem = "delete"
	SubsystemCreate     LogSubsystem = "create"
	SubsystemRead       LogSubsystem = "read"
	SubsystemUpdate     LogSubsystem = "update"
	SubsystemSync       LogSubsystem = "sync"       // For synchronization operations
	SubsystemAPI        LogSubsystem = "api"        // For direct API interaction logs
	SubsystemRetry      LogSubsystem = "retry"      // For retry logic
	SubsystemValidation LogSubsystem = "validation" // For input validation
	SubsystemConfig     LogSubsystem = "config"     // For configuration-related logs
	SubsystemInit       LogSubsystem = "init"       // For provider initialization
	SubsystemCleanup    LogSubsystem = "cleanup"    // For cleanup operations
	SubsystemConstruct  LogSubsystem = "construct"  // For resource construction operations

)

type NullDiagnosticLogger

type NullDiagnosticLogger struct{}

NullDiagnosticLogger is an implementation of the DiagnosticLogger interface that disregards log output.

func (NullDiagnosticLogger) Error

func (NullDiagnosticLogger) Error(_ string, _ string, _ ...interface{})

Error disregards the error log output.

func (NullDiagnosticLogger) Errorf

func (NullDiagnosticLogger) Errorf(_ string, _ ...interface{})

Errorf disregards the formatted error log output.

func (NullDiagnosticLogger) Info

func (NullDiagnosticLogger) Info(_ string)

Info disregards the informational log output.

func (NullDiagnosticLogger) Infof

func (NullDiagnosticLogger) Infof(_ string, _ ...interface{})

Infof disregards the formatted informational log output.

func (NullDiagnosticLogger) Warn

func (NullDiagnosticLogger) Warn(_ string, _ string, _ ...interface{})

Warn disregards the warning log output.

func (NullDiagnosticLogger) Warnf

func (NullDiagnosticLogger) Warnf(_ string, _ ...interface{})

Warnf disregards the formatted warning log output.

Jump to

Keyboard shortcuts

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