Files
traefikoidc/internal/utils/logger_wrapper.go
T
lukaszraczylo e64fc7f730 Add redis support for distributed caching (#83)
* Add redis support for distributed caching

* Move towards the self-provided Redis connection pool and RESP protocol implementation.
Official redis client library won't work with yaegi.

* fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* ... and another all nighter.

* fixup! ... and another all nighter.

* fixup! fixup! ... and another all nighter.

* fixup! fixup! fixup! ... and another all nighter.

* Resolve issue #85 by adding ability to set custom claims in JWT tokens

* Remove redundant validation in auth middleware ( issue #89 )

* Add ability to set cookie prefix for session cookies ( #87 )

* fixup! Add ability to set cookie prefix for session cookies ( #87 )

* Add ability to set cookie max age - issue #91

* Potential fix for code scanning alert no. 10: Size computation for allocation may overflow

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fixup! Merge main into 0.8.0-redis: resolve conflicts

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-11-30 02:18:46 +00:00

92 lines
2.8 KiB
Go

package utils
import (
"github.com/lukaszraczylo/traefikoidc/internal/cleanup"
"github.com/lukaszraczylo/traefikoidc/internal/recovery"
)
// LoggerInterface defines the common logger interface used across the package
type LoggerInterface interface {
Infof(format string, args ...interface{})
Debugf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
// ============================================================================
// RECOVERY LOGGER WRAPPER
// ============================================================================
// recoveryLoggerWrapper wraps a logger to match recovery.Logger interface
type recoveryLoggerWrapper struct {
logger LoggerInterface
}
// WrapLoggerForRecovery wraps a logger for use with recovery modules
func WrapLoggerForRecovery(logger LoggerInterface) recovery.Logger {
return &recoveryLoggerWrapper{logger: logger}
}
// Logf logs an informational message
func (lw *recoveryLoggerWrapper) Logf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Infof(format, args...)
}
}
// ErrorLogf logs an error message
func (lw *recoveryLoggerWrapper) ErrorLogf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Errorf(format, args...)
}
}
// DebugLogf logs a debug message
func (lw *recoveryLoggerWrapper) DebugLogf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Debugf(format, args...)
}
}
// ============================================================================
// CLEANUP LOGGER WRAPPER
// ============================================================================
// cleanupLoggerWrapper wraps a logger to match cleanup.Logger interface
type cleanupLoggerWrapper struct {
logger LoggerInterface
}
// WrapLoggerForCleanup wraps a logger for use with cleanup modules
func WrapLoggerForCleanup(logger LoggerInterface) cleanup.Logger {
return &cleanupLoggerWrapper{logger: logger}
}
// Logf logs an informational message
func (lw *cleanupLoggerWrapper) Logf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Infof(format, args...)
}
}
// ErrorLogf logs an error message
func (lw *cleanupLoggerWrapper) ErrorLogf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Errorf(format, args...)
}
}
// DebugLogf logs a debug message
func (lw *cleanupLoggerWrapper) DebugLogf(format string, args ...interface{}) {
if lw.logger != nil {
lw.logger.Debugf(format, args...)
}
}
// ============================================================================
// SESSION LOGGER WRAPPER
// ============================================================================
// Note: Session logger wrapper is not included here because session.Logger
// has a different interface (Debug/Info/Warn/Error instead of Logf/ErrorLogf/DebugLogf).
// Each package should implement its own session logger adapter as needed.