- Async Logger - 45x performance boost (3,358ns → 75ns), supports 100k+ QPS
- Sampling Logger - 29x performance boost (3,357ns → 116ns), intelligent frequency control
- Sanitizer Logger - Auto-sanitize sensitive data (phone, password, email, etc.), compliance-ready
- Logrus Adapter - Full Logrus ecosystem support with 50+ hooks available
- Production-Ready Config - Built-in best practices (async + sampling + sanitization)
- Concurrency Safe - Verified with Race Detector, zero data races
- Gin middleware - Login, refresh and identity handling for Gin applications
- Bounded token lifetime -
MaxRefreshcaps how long a token may be renewed for, measured from its original issuance - Configurable -
TimeoutandMaxRefreshare both driven by configuration
- Cache component (memory support)
- Queue component (memory support)
- Configuration management (multiple data sources)
- Log writer (file rotation support)
Latest Version: Go 1.25 | 35 unit tests + 30+ performance benchmarks
go get -u github.com/go-admin-team/go-admin-coreSystem Requirements: Go 1.25 or higher (see the go directive in go.mod)
package main
import "github.com/go-admin-team/go-admin-core/logger"
func main() {
// Create Logrus logger instance
log := logger.NewLogrusLogger(
logger.WithPath("logs/app.log"),
logger.WithLevel(logger.InfoLevel),
)
log.Log(logger.InfoLevel, "Application started")
log.Fields(map[string]interface{}{
"user_id": 12345,
"action": "login",
}).Log(logger.InfoLevel, "User action")
}// Create async logger (recommended for high-concurrency scenarios)
baseLog := logger.NewLogrusLogger(
logger.WithPath("logs/app.log"),
logger.WithLevel(logger.InfoLevel),
)
asyncLog := logger.NewAsyncLogger(baseLog, logger.DefaultAsyncConfig)
defer asyncLog.(interface{ Close() error }).Close()
// 45x performance boost, only 75ns latency
asyncLog.Log(logger.InfoLevel, "High performance logging")// Create sampling logger (auto-filter high-frequency duplicate logs)
samplingLog := logger.NewSamplingLogger(baseLog, logger.DefaultSamplingConfig)
// Only logs first 100 per second, then 1 out of every 100
for i := 0; i < 10000; i++ {
samplingLog.Log(logger.InfoLevel, "High frequency log")
}// Create sanitizer logger (auto-handle sensitive data)
sanitizerLog := logger.NewSanitizerLogger(baseLog, logger.DefaultSanitizerConfig)
sanitizerLog.Fields(map[string]interface{}{
"phone": "13812345678", // Auto-sanitized → "138****5678"
"password": "secret123", // Auto-sanitized → "[REDACTED]"
"email": "user@example.com", // Auto-sanitized → "u***@example.com"
}).Log(logger.InfoLevel, "User login")// Combine: Sanitizer → Sampling → Async
sanitized := logger.NewSanitizerLogger(baseLog, logger.DefaultSanitizerConfig)
sampled := logger.NewSamplingLogger(sanitized, logger.DefaultSamplingConfig)
asyncLog := logger.NewAsyncLogger(sampled, logger.DefaultAsyncConfig)
defer asyncLog.(interface{ Close() error }).Close()
// 34x performance boost + data security + frequency control
asyncLog.Fields(map[string]interface{}{
"phone": "13812345678",
"user_id": 12345,
}).Log(logger.InfoLevel, "Production logging")package main
import "github.com/go-admin-team/go-admin-core/config"
func main() {
source := config.FileSource("config.json")
config.Setup(source, func() {
// Configuration change callback
})
}| Feature | Performance Boost | Latency | Memory | Use Case |
|---|---|---|---|---|
| Async Logger | 45x | 75ns | 120 B/op | High-concurrency writes |
| Sampling Logger | 29x | 116ns | 16 B/op | High-frequency duplicate logs |
| Production Config | 34x | 98ns | 149 B/op | Production environments |
Test Environment: Apple M1 Pro | Go 1.25.1 | Race Detector verified
# Run all tests
go test ./... -v
# Performance benchmarks
go test ./logger -bench=. -benchmem
# Concurrency safety check
go test ./logger -raceTest Results:
- ✅ Unit Tests: 35/35 passed
- ✅ Performance Benchmarks: 30+ passed
- ✅ Concurrency Safety: Race Detector 0 warnings
- ✅ Code Coverage: 85%+
github.com/casbin/casbin/v3 v3.8.1
github.com/gin-gonic/gin v1.11.0
github.com/golang-jwt/jwt/v5 v5.3.0
gorm.io/gorm v1.31.1
github.com/sirupsen/logrus v1.9.4
golang.org/x/crypto v0.47.0Versions above reflect go.mod at the time of writing; that file is the source
of truth.
We welcome Issues and Pull Requests!
- Fork this repository
- Create your feature branch from
main(git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request against
main
Branches:
mainis the only active branch and the source of every release.masteranddevare historical and no longer accept changes —masterin particular has not moved since 2022 and was never part of the release lineage.
Please do not open a public issue for security problems. Use private vulnerability reporting instead.
Apache License 2.0 - See LICENSE file for details
- go-admin - Gin + Vue + Element UI based RBAC system with separated frontend/backend
- go-admin-ui - go-admin frontend project
If this project helps you, please give us a Star ⭐