Documentation
¶
Overview ¶
Package logger provides comprehensive logging capabilities for the AhaSend CLI.
This package implements multi-level logging with security-aware features:
- Structured logging using logrus, as text lines of key=value fields
- HTTP transport logging for API debugging (request/response details)
- Security-aware log sanitization (API keys and sensitive headers redacted)
- Two-level logging: --verbose (API summaries) and --debug (full details)
- Configuration operation logging for troubleshooting
- Request timing
- Color-coded output when terminal.UseColor says so for stderr
The logger automatically detects and redacts sensitive information while providing comprehensive debugging information for development and support.
Index ¶
- func ConfigOperation(operation, profile string, details map[string]interface{})
- func Debug(args ...interface{})
- func Initialize(cmd *cobra.Command)
- func Redirect(w io.Writer) (restore func())
- type HTTPTransport
- type Logger
- func (l *Logger) APICall(method, endpoint string, duration time.Duration)
- func (l *Logger) APIError(method, endpoint string, statusCode int, err error, duration time.Duration)
- func (l *Logger) ConfigOperation(operation, profile string, details map[string]interface{})
- func (l *Logger) HTTPRequest(method, url string, headers http.Header, body interface{})
- func (l *Logger) HTTPResponse(statusCode int, status string, headers http.Header, body interface{}, ...)
- func (l *Logger) IsDebugEnabled() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigOperation ¶
func Initialize ¶
Initialize sets up the global logger based on CLI flags. Logs go to the command's stderr in every output format, so they never mix with stdout.
Types ¶
type HTTPTransport ¶
type HTTPTransport struct {
// contains filtered or unexported fields
}
HTTPTransport is a custom RoundTripper that logs HTTP requests and responses
func NewHTTPTransport ¶
func NewHTTPTransport(transport http.RoundTripper, logger *Logger) *HTTPTransport
NewHTTPTransport creates a new HTTP transport with logging
type Logger ¶
Logger wraps logrus with CLI-specific functionality
func (*Logger) APIError ¶
func (l *Logger) APIError(method, endpoint string, statusCode int, err error, duration time.Duration)
APIError logs a failed API call in verbose and debug modes. The command reports the error itself, so other modes log nothing.
func (*Logger) ConfigOperation ¶
ConfigOperation logs configuration operations
func (*Logger) HTTPRequest ¶
HTTPRequest logs HTTP request details
func (*Logger) HTTPResponse ¶
func (l *Logger) HTTPResponse(statusCode int, status string, headers http.Header, body interface{}, duration time.Duration)
HTTPResponse logs HTTP response details
func (*Logger) IsDebugEnabled ¶
IsDebugEnabled returns true if debug mode is enabled