mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Delete more debug logs
This commit is contained in:
@@ -26,7 +26,7 @@ func main() {
|
||||
|
||||
// Setup logging
|
||||
logging.Setup(cfg.LogLevel)
|
||||
logging.Debug("Configuration loaded", "config", logging.Redact(cfg))
|
||||
logging.Debug("Configuration loaded", "config", cfg.Redact())
|
||||
|
||||
// Initialize and start server
|
||||
options, err := app.DefaultOptions(cfg)
|
||||
|
||||
@@ -19,10 +19,10 @@ type Config struct {
|
||||
RootURL string
|
||||
Domain string
|
||||
CORSOrigins []string
|
||||
AdminEmail string `log:"redact"`
|
||||
AdminPassword string `log:"redact"`
|
||||
EncryptionKey string `log:"redact"`
|
||||
JWTSigningKey string `log:"redact"`
|
||||
AdminEmail string
|
||||
AdminPassword string
|
||||
EncryptionKey string
|
||||
JWTSigningKey string
|
||||
RateLimitRequests int
|
||||
RateLimitWindow time.Duration
|
||||
IsDevelopment bool
|
||||
@@ -56,6 +56,16 @@ func (c *Config) validate() error {
|
||||
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
|
||||
func LoadConfig() (*Config, error) {
|
||||
config := DefaultConfig()
|
||||
|
||||
@@ -52,8 +52,6 @@ type jwtService struct {
|
||||
// NewJWTService creates a new JWT service with the provided configuration
|
||||
// Returns an error if the signing key is missing
|
||||
func NewJWTService(config JWTConfig) (JWTManager, error) {
|
||||
log := getJWTLogger()
|
||||
|
||||
if config.SigningKey == "" {
|
||||
return nil, fmt.Errorf("signing key is required")
|
||||
}
|
||||
@@ -66,10 +64,6 @@ func NewJWTService(config JWTConfig) (JWTManager, error) {
|
||||
config.RefreshTokenExpiry = 7 * 24 * time.Hour
|
||||
}
|
||||
|
||||
log.Info("initialized JWT service",
|
||||
"accessExpiry", config.AccessTokenExpiry,
|
||||
"refreshExpiry", config.RefreshTokenExpiry)
|
||||
|
||||
return &jwtService{config: config}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,6 @@ func Init(dbPath string, secretsService secrets.Service) (Database, error) {
|
||||
if err := db.Ping(); err != nil {
|
||||
return nil, fmt.Errorf("failed to ping database: %w", err)
|
||||
}
|
||||
log.Debug("database ping successful")
|
||||
|
||||
// Enable foreign keys for this connection
|
||||
if _, err := db.Exec("PRAGMA foreign_keys = ON"); err != nil {
|
||||
|
||||
@@ -4,7 +4,6 @@ package logging
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// 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
|
||||
func (l *logger) Debug(msg string, args ...any) {
|
||||
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
|
||||
func NewService(key string) (Service, error) {
|
||||
log := getLogger()
|
||||
keyBytes, err := decodeAndValidateKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -80,7 +79,6 @@ func NewService(key string) (Service, error) {
|
||||
return nil, fmt.Errorf("failed to create GCM: %w", err)
|
||||
}
|
||||
|
||||
log.Info("encryption service created")
|
||||
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.
|
||||
func NewService(rootDir string) *Service {
|
||||
getLogger().Debug("creating new storage service",
|
||||
"rootDir", rootDir,
|
||||
"options", "default")
|
||||
return NewServiceWithOptions(rootDir, Options{
|
||||
Fs: &osFS{},
|
||||
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.
|
||||
func NewServiceWithOptions(rootDir string, options Options) *Service {
|
||||
log := getLogger()
|
||||
log.Debug("creating new storage service with custom options",
|
||||
"rootDir", rootDir)
|
||||
|
||||
if options.Fs == nil {
|
||||
options.Fs = &osFS{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user