Documentation
¶
Index ¶
Constants ¶
View Source
const (
// LoggerNameKey is a key we can use to denote logger names across implementations.
LoggerNameKey = "service_name"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level *level
Level is a simple string alias for dependency injection's sake.
var ( // InfoLevel describes a info-level log. InfoLevel Level = new(level("info")) // DebugLevel describes a debug-level log. DebugLevel Level = new(level("debug")) // ErrorLevel describes a error-level log. ErrorLevel Level = new(level("error")) // WarnLevel describes a warn-level log. WarnLevel Level = new(level("warn")) )
type Logger ¶
type Logger interface {
Info(string)
Debug(string)
Error(whatWasHappeningWhenErrorOccurred string, err error)
SetRequestIDFunc(RequestIDFunc)
Clone() Logger
WithName(string) Logger
WithValues(map[string]any) Logger
WithValue(string, any) Logger
WithRequest(*http.Request) Logger
WithResponse(response *http.Response) Logger
WithError(error) Logger
WithSpan(span trace.Span) Logger
}
Logger represents a simple logging interface we can build wrappers around. NOTICE: someone, naive and green, may be enticed to add a method to this interface akin to: WithQueryFilter(*types.QueryFilter) Logger This is a fool's errand, it would introduce a disallowed import cycle.
func EnsureLogger ¶
EnsureLogger guarantees that a Logger is available.
func NewNoopLogger ¶
func NewNoopLogger() Logger
NewNoopLogger provides our noop Logger to dependency manager.
type RequestIDFunc ¶
RequestIDFunc fetches a string ID from a request.
type RequestInfo ¶
RequestInfo holds HTTP request metadata extracted for logging.
func ExtractRequestInfo ¶
func ExtractRequestInfo(req *http.Request, requestIDFunc RequestIDFunc) RequestInfo
ExtractRequestInfo extracts logging-relevant fields from an HTTP request.
Click to show internal directories.
Click to hide internal directories.