ax(logging): rename mu to mutex for predictable naming

AX Principle 1: abbreviated field names increase semantic ambiguity.
Logger.mu renamed to Logger.mutex — no comment required to understand it.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 14:22:38 +01:00
parent 2eeaf47b3c
commit 44223f0c67
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -42,7 +42,7 @@ func (l Level) String() string {
// Logger provides structured logging with configurable output and level.
type Logger struct {
mu sync.Mutex
mutex sync.Mutex
output io.Writer
level Level
component string
@ -91,8 +91,8 @@ func (l *Logger) WithComponent(component string) *Logger {
// SetLevel adjusts the minimum level for subsequent log calls.
// logger.SetLevel(logging.LevelDebug)
func (l *Logger) SetLevel(level Level) {
l.mu.Lock()
defer l.mu.Unlock()
l.mutex.Lock()
defer l.mutex.Unlock()
l.level = level
}
@ -100,8 +100,8 @@ func (l *Logger) SetLevel(level Level) {
// current := logger.GetLevel()
// if current == logging.LevelDebug { logger.SetLevel(logging.LevelInfo) }
func (l *Logger) GetLevel() Level {
l.mu.Lock()
defer l.mu.Unlock()
l.mutex.Lock()
defer l.mutex.Unlock()
return l.level
}
@ -110,8 +110,8 @@ type Fields map[string]interface{}
// log writes a log message at the specified level.
func (l *Logger) log(level Level, msg string, fields Fields) {
l.mu.Lock()
defer l.mu.Unlock()
l.mutex.Lock()
defer l.mutex.Unlock()
if level < l.level {
return