mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Delete more debug logs
This commit is contained in:
@@ -26,7 +26,7 @@ func main() {
|
|||||||
|
|
||||||
// Setup logging
|
// Setup logging
|
||||||
logging.Setup(cfg.LogLevel)
|
logging.Setup(cfg.LogLevel)
|
||||||
logging.Debug("Configuration loaded", "config", logging.Redact(cfg))
|
logging.Debug("Configuration loaded", "config", cfg.Redact())
|
||||||
|
|
||||||
// Initialize and start server
|
// Initialize and start server
|
||||||
options, err := app.DefaultOptions(cfg)
|
options, err := app.DefaultOptions(cfg)
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ type Config struct {
|
|||||||
RootURL string
|
RootURL string
|
||||||
Domain string
|
Domain string
|
||||||
CORSOrigins []string
|
CORSOrigins []string
|
||||||
AdminEmail string `log:"redact"`
|
AdminEmail string
|
||||||
AdminPassword string `log:"redact"`
|
AdminPassword string
|
||||||
EncryptionKey string `log:"redact"`
|
EncryptionKey string
|
||||||
JWTSigningKey string `log:"redact"`
|
JWTSigningKey string
|
||||||
RateLimitRequests int
|
RateLimitRequests int
|
||||||
RateLimitWindow time.Duration
|
RateLimitWindow time.Duration
|
||||||
IsDevelopment bool
|
IsDevelopment bool
|
||||||
@@ -56,6 +56,16 @@ func (c *Config) validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redact redacts sensitive fields from a Config instance
|
||||||
|
func (c *Config) Redact() *Config {
|
||||||
|
redacted := *c
|
||||||
|
redacted.AdminPassword = "[REDACTED]"
|
||||||
|
redacted.AdminEmail = "[REDACTED]"
|
||||||
|
redacted.EncryptionKey = "[REDACTED]"
|
||||||
|
redacted.JWTSigningKey = "[REDACTED]"
|
||||||
|
return &redacted
|
||||||
|
}
|
||||||
|
|
||||||
// LoadConfig creates a new Config instance with values from environment variables
|
// LoadConfig creates a new Config instance with values from environment variables
|
||||||
func LoadConfig() (*Config, error) {
|
func LoadConfig() (*Config, error) {
|
||||||
config := DefaultConfig()
|
config := DefaultConfig()
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ type jwtService struct {
|
|||||||
// NewJWTService creates a new JWT service with the provided configuration
|
// NewJWTService creates a new JWT service with the provided configuration
|
||||||
// Returns an error if the signing key is missing
|
// Returns an error if the signing key is missing
|
||||||
func NewJWTService(config JWTConfig) (JWTManager, error) {
|
func NewJWTService(config JWTConfig) (JWTManager, error) {
|
||||||
log := getJWTLogger()
|
|
||||||
|
|
||||||
if config.SigningKey == "" {
|
if config.SigningKey == "" {
|
||||||
return nil, fmt.Errorf("signing key is required")
|
return nil, fmt.Errorf("signing key is required")
|
||||||
}
|
}
|
||||||
@@ -66,10 +64,6 @@ func NewJWTService(config JWTConfig) (JWTManager, error) {
|
|||||||
config.RefreshTokenExpiry = 7 * 24 * time.Hour
|
config.RefreshTokenExpiry = 7 * 24 * time.Hour
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("initialized JWT service",
|
|
||||||
"accessExpiry", config.AccessTokenExpiry,
|
|
||||||
"refreshExpiry", config.RefreshTokenExpiry)
|
|
||||||
|
|
||||||
return &jwtService{config: config}, nil
|
return &jwtService{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ func Init(dbPath string, secretsService secrets.Service) (Database, error) {
|
|||||||
if err := db.Ping(); err != nil {
|
if err := db.Ping(); err != nil {
|
||||||
return nil, fmt.Errorf("failed to ping database: %w", err)
|
return nil, fmt.Errorf("failed to ping database: %w", err)
|
||||||
}
|
}
|
||||||
log.Debug("database ping successful")
|
|
||||||
|
|
||||||
// Enable foreign keys for this connection
|
// Enable foreign keys for this connection
|
||||||
if _, err := db.Exec("PRAGMA foreign_keys = ON"); err != nil {
|
if _, err := db.Exec("PRAGMA foreign_keys = ON"); err != nil {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package logging
|
|||||||
import (
|
import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Logger represents the interface for logging operations
|
// Logger represents the interface for logging operations
|
||||||
@@ -61,27 +60,6 @@ func ParseLogLevel(level string) LogLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redact redacts sensitive fields from a struct based on the `log` struct tag
|
|
||||||
// if the tag is set to "redact" the field value is replaced with "[REDACTED]"
|
|
||||||
func Redact(v any) map[string]any {
|
|
||||||
result := make(map[string]any)
|
|
||||||
val := reflect.ValueOf(v)
|
|
||||||
typ := val.Type()
|
|
||||||
|
|
||||||
for i := 0; i < val.NumField(); i++ {
|
|
||||||
field := typ.Field(i)
|
|
||||||
if tag := field.Tag.Get("log"); tag != "" {
|
|
||||||
switch tag {
|
|
||||||
case "redact":
|
|
||||||
result[field.Name] = "[REDACTED]"
|
|
||||||
default:
|
|
||||||
result[field.Name] = val.Field(i).Interface()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implementation of Logger interface methods
|
// Implementation of Logger interface methods
|
||||||
func (l *logger) Debug(msg string, args ...any) {
|
func (l *logger) Debug(msg string, args ...any) {
|
||||||
l.logger.Debug(msg, args...)
|
l.logger.Debug(msg, args...)
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ func decodeAndValidateKey(key string) ([]byte, error) {
|
|||||||
|
|
||||||
// NewService creates a new Encryptor instance with the provided base64-encoded key
|
// NewService creates a new Encryptor instance with the provided base64-encoded key
|
||||||
func NewService(key string) (Service, error) {
|
func NewService(key string) (Service, error) {
|
||||||
log := getLogger()
|
|
||||||
keyBytes, err := decodeAndValidateKey(key)
|
keyBytes, err := decodeAndValidateKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -80,7 +79,6 @@ func NewService(key string) (Service, error) {
|
|||||||
return nil, fmt.Errorf("failed to create GCM: %w", err)
|
return nil, fmt.Errorf("failed to create GCM: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("encryption service created")
|
|
||||||
return &encryptor{gcm: gcm}, nil
|
return &encryptor{gcm: gcm}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ type Options struct {
|
|||||||
|
|
||||||
// NewService creates a new Storage instance with the default options and the given rootDir root directory.
|
// NewService creates a new Storage instance with the default options and the given rootDir root directory.
|
||||||
func NewService(rootDir string) *Service {
|
func NewService(rootDir string) *Service {
|
||||||
getLogger().Debug("creating new storage service",
|
|
||||||
"rootDir", rootDir,
|
|
||||||
"options", "default")
|
|
||||||
return NewServiceWithOptions(rootDir, Options{
|
return NewServiceWithOptions(rootDir, Options{
|
||||||
Fs: &osFS{},
|
Fs: &osFS{},
|
||||||
NewGitClient: git.New,
|
NewGitClient: git.New,
|
||||||
@@ -38,10 +35,6 @@ func NewService(rootDir string) *Service {
|
|||||||
|
|
||||||
// NewServiceWithOptions creates a new Storage instance with the given options and the given rootDir root directory.
|
// NewServiceWithOptions creates a new Storage instance with the given options and the given rootDir root directory.
|
||||||
func NewServiceWithOptions(rootDir string, options Options) *Service {
|
func NewServiceWithOptions(rootDir string, options Options) *Service {
|
||||||
log := getLogger()
|
|
||||||
log.Debug("creating new storage service with custom options",
|
|
||||||
"rootDir", rootDir)
|
|
||||||
|
|
||||||
if options.Fs == nil {
|
if options.Fs == nil {
|
||||||
options.Fs = &osFS{}
|
options.Fs = &osFS{}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user