Documentation
¶
Overview ¶
Package utils provides common utility functions for the GitCells application.
Index ¶
- func GetLogFilePath() string
- func LogError(logger *logrus.Logger, err error, operation string, ...)
- func LogErrorDefault(err error, message string, fields map[string]interface{})
- func LogErrorWithRetry(logger *logrus.Logger, err error, attempt, maxAttempts int)
- func LogInfo(message string, fields map[string]interface{})
- func LogModeChange(fromMode, toMode string)
- func LogUserAction(action string, fields map[string]interface{})
- func LogValidationError(field string, value interface{}, reason string)
- func LogWarn(message string, fields map[string]interface{})
- func LoggerWithFields(logger *logrus.Logger, fields logrus.Fields) *logrus.Entry
- func LoggerWithFile(logger *logrus.Logger, file string) *logrus.Entry
- func LoggerWithOperation(logger *logrus.Logger, operation string) *logrus.Entry
- func NewLogger(config *LogConfig) *logrus.Logger
- func NewVerboseLogger() *logrus.Logger
- func Retry(operation RetryableOperation, config *RetryConfig) error
- func RotateLogFile(maxSizeBytes int64) error
- type ErrorCollector
- func (ec *ErrorCollector) Add(err error)
- func (ec *ErrorCollector) AddContext(err error, context string)
- func (ec *ErrorCollector) Count() int
- func (ec *ErrorCollector) Error() string
- func (ec *ErrorCollector) Errors() []error
- func (ec *ErrorCollector) First() error
- func (ec *ErrorCollector) HasErrors() bool
- type ErrorContextHook
- type ErrorType
- type GitCellsError
- type GitCellsFormatter
- type LogConfig
- type LogFormat
- type LogLevel
- type Progress
- type RetryConfig
- type RetryableOperation
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLogFilePath ¶
func GetLogFilePath() string
GetLogFilePath returns the path where log files are stored
func LogErrorDefault ¶
LogErrorDefault logs an error using the default logger
func LogErrorWithRetry ¶
LogErrorWithRetry logs an error with retry context
func LogModeChange ¶
func LogModeChange(fromMode, toMode string)
LogModeChange logs when the user changes TUI modes
func LogUserAction ¶
LogUserAction logs user actions in the TUI
func LogValidationError ¶
LogValidationError logs validation errors with context
func LoggerWithFields ¶
LoggerWithFields returns a logger with multiple fields set
func LoggerWithFile ¶
LoggerWithFile creates a logger with file context
func LoggerWithOperation ¶
LoggerWithOperation creates a logger with operation context
func NewVerboseLogger ¶
NewVerboseLogger creates a logger for verbose mode
func Retry ¶
func Retry(operation RetryableOperation, config *RetryConfig) error
Retry executes an operation with retry logic
func RotateLogFile ¶
RotateLogFile rotates the log file if it exceeds the maximum size
Types ¶
type ErrorCollector ¶
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector collects multiple errors and provides a summary
func NewErrorCollector ¶
func NewErrorCollector(limit int) *ErrorCollector
NewErrorCollector creates a new error collector with optional limit
func (*ErrorCollector) Add ¶
func (ec *ErrorCollector) Add(err error)
Add adds an error to the collection
func (*ErrorCollector) AddContext ¶
func (ec *ErrorCollector) AddContext(err error, context string)
AddContext adds an error with additional context
func (*ErrorCollector) Count ¶
func (ec *ErrorCollector) Count() int
Count returns the number of collected errors
func (*ErrorCollector) Error ¶
func (ec *ErrorCollector) Error() string
Error implements the error interface, providing a summary of all errors
func (*ErrorCollector) Errors ¶
func (ec *ErrorCollector) Errors() []error
Errors returns all collected errors
func (*ErrorCollector) First ¶
func (ec *ErrorCollector) First() error
First returns the first error, or nil if none
func (*ErrorCollector) HasErrors ¶
func (ec *ErrorCollector) HasErrors() bool
HasErrors returns true if any errors were collected
type ErrorContextHook ¶
type ErrorContextHook struct{}
ErrorContextHook adds error context to log entries
func (*ErrorContextHook) Fire ¶
func (hook *ErrorContextHook) Fire(entry *logrus.Entry) error
Fire is called when a log entry is made
func (*ErrorContextHook) Levels ¶
func (hook *ErrorContextHook) Levels() []logrus.Level
Levels returns the log levels this hook should fire for
type ErrorType ¶
type ErrorType string
ErrorType represents different categories of errors
const ( ErrorTypeConverter ErrorType = "CONVERTER" ErrorTypeGit ErrorType = "GIT" ErrorTypeWatcher ErrorType = "WATCHER" ErrorTypeConfig ErrorType = "CONFIG" ErrorTypeValidation ErrorType = "VALIDATION" ErrorTypeFileSystem ErrorType = "FILESYSTEM" ErrorTypeNetwork ErrorType = "NETWORK" ErrorTypeConflict ErrorType = "CONFLICT" ErrorTypePermission ErrorType = "PERMISSION" ErrorTypeCorruption ErrorType = "CORRUPTION" )
type GitCellsError ¶
type GitCellsError struct {
Type ErrorType
Operation string
File string
Cause error
Message string
Recoverable bool
}
GitCellsError represents a custom error type for GitCells operations
func NewError ¶
func NewError(errorType ErrorType, operation, message string) *GitCellsError
NewError creates a new GitCellsError
func WrapError ¶
func WrapError(err error, errorType ErrorType, operation, message string) *GitCellsError
WrapError wraps an existing error with GitCells context
func WrapFileError ¶
func WrapFileError(err error, errorType ErrorType, operation, file, message string) *GitCellsError
WrapFileError wraps an error with file context
func (*GitCellsError) Error ¶
func (e *GitCellsError) Error() string
Error implements the error interface
func (*GitCellsError) IsRecoverable ¶
func (e *GitCellsError) IsRecoverable() bool
IsRecoverable returns whether the error is recoverable
func (*GitCellsError) Unwrap ¶
func (e *GitCellsError) Unwrap() error
Unwrap returns the underlying error
type GitCellsFormatter ¶
type GitCellsFormatter struct {
DisableColors bool
FullTimestamp bool
TimestampFormat string
AddSource bool
}
GitCellsFormatter is a custom formatter for GitCells
type LogConfig ¶
type LogConfig struct {
Level LogLevel
Format LogFormat
Output io.Writer
File string
MaxSize int64 // Max file size in bytes
MaxAge int // Max age in days
AddSource bool // Add source file and line
NoColors bool // Disable colors in text format
}
LogConfig configures logger behavior
func DefaultLogConfig ¶
func DefaultLogConfig() *LogConfig
DefaultLogConfig returns sensible defaults
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress represents a progress tracker for logging
func NewProgress ¶
NewProgress creates a new progress tracker
type RetryConfig ¶
RetryConfig configures retry behavior
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns a sensible default retry configuration
type RetryableOperation ¶
type RetryableOperation func() error
RetryableOperation represents an operation that can be retried
type ValidationError ¶
ValidationError represents a validation error with field context
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
Error implements the error interface
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors represents multiple validation errors
func (*ValidationErrors) Add ¶
func (ve *ValidationErrors) Add(field string, value interface{}, message string)
Add adds a validation error
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string
Error implements the error interface
func (ValidationErrors) HasErrors ¶
func (ve ValidationErrors) HasErrors() bool
HasErrors returns true if there are validation errors