logger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigOperation

func ConfigOperation(operation, profile string, details map[string]interface{})

func Debug

func Debug(args ...interface{})

Global convenience functions

func Initialize

func Initialize(cmd *cobra.Command)

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.

func Redirect added in v0.3.0

func Redirect(w io.Writer) (restore func())

Redirect sends the logs to w until the returned function sends them back where they went before, such as while a progress bar owns stderr.

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

func (*HTTPTransport) RoundTrip

func (t *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface. In debug mode it reads and closes the request body and sends a clone carrying a copy of it, so the caller's request is never modified.

type Logger

type Logger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

Logger wraps logrus with CLI-specific functionality

func Get

func Get() *Logger

Get returns the global logger instance

func (*Logger) APICall

func (l *Logger) APICall(method, endpoint string, duration time.Duration)

APICall logs API call details at info level (for verbose mode)

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

func (l *Logger) ConfigOperation(operation, profile string, details map[string]interface{})

ConfigOperation logs configuration operations

func (*Logger) HTTPRequest

func (l *Logger) HTTPRequest(method, url string, headers http.Header, body interface{})

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

func (l *Logger) IsDebugEnabled() bool

IsDebugEnabled returns true if debug mode is enabled

Jump to

Keyboard shortcuts

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