Implement structured logging with slog

- Replace zerolog with Go's standard slog package
- Add ColorHandler for terminal color output
- Add context-aware logging system
- Format attributes on the same line as log messages
- Use green color for INFO level logs
- Set up context value extraction helpers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-05-22 12:44:08 +03:00
parent ad224a328e
commit a55f820f62
7 changed files with 393 additions and 322 deletions

View File

@@ -1,49 +0,0 @@
package hostPool
import (
"sync"
"time"
"gemini-grc/logging"
)
var hostPool = HostPool{hostnames: make(map[string]struct{})} //nolint:gochecknoglobals
type HostPool struct {
hostnames map[string]struct{}
lock sync.RWMutex
}
//func (p *HostPool) add(key string) {
// p.lock.Lock()
// defer p.lock.Unlock()
// p.hostnames[key] = struct{}{}
//}
//
//func (p *HostPool) has(key string) bool {
// p.lock.RLock()
// defer p.lock.RUnlock()
// _, ok := p.hostnames[key]
// return ok
//}
func RemoveHostFromPool(key string) {
hostPool.lock.Lock()
defer hostPool.lock.Unlock()
delete(hostPool.hostnames, key)
}
func AddHostToHostPool(key string) {
for {
hostPool.lock.Lock()
_, exists := hostPool.hostnames[key]
if !exists {
hostPool.hostnames[key] = struct{}{}
hostPool.lock.Unlock()
return
}
hostPool.lock.Unlock()
time.Sleep(1 * time.Second)
logging.LogInfo("Waiting to add %s to pool...", key)
}
}