Files
Charon/backend/internal/logger/logger.go
GitHub Actions 34347b1ff5 Refactor uptime service and tests; add WAF configuration UI and e2e tests
- Refactored `SyncMonitors` method in `uptime_service.go` for better readability.
- Updated unit tests for `UptimeService` to ensure proper functionality.
- Introduced Playwright configuration for end-to-end testing.
- Added e2e tests for WAF blocking and monitoring functionality.
- Enhanced the Security page to include WAF mode and rule set selection.
- Implemented tests for WAF configuration changes and validation.
- Created a `.last-run.json` file to store test results.
2025-12-02 02:51:50 +00:00

36 lines
745 B
Go

package logger
import (
"io"
"os"
"github.com/sirupsen/logrus"
)
var _log = logrus.New()
// Init initializes the global logger with output writer and debug level.
func Init(debug bool, out io.Writer) {
if out == nil {
out = os.Stdout
}
_log.SetOutput(out)
if debug {
_log.SetLevel(logrus.DebugLevel)
_log.SetFormatter(&logrus.TextFormatter{FullTimestamp: true})
} else {
_log.SetLevel(logrus.InfoLevel)
_log.SetFormatter(&logrus.JSONFormatter{})
}
}
// Log returns a standard logger entry to use across packages.
func Log() *logrus.Entry {
return logrus.NewEntry(_log)
}
// WithFields returns a logger entry with provided fields.
func WithFields(fields logrus.Fields) *logrus.Entry {
return Log().WithFields(fields)
}