Run CI on push to master and bump Go to 1.26.0 (#1)
CI / check-and-test (push) Successful in 11s

Also serialize logger.Init vs GetLogger so -race is green.
This commit was merged in pull request #1.
This commit is contained in:
s1d3sw1ped_bot
2026-08-31 18:59:18 -05:00
3 changed files with 35 additions and 23 deletions
+7 -4
View File
@@ -1,6 +1,9 @@
name: PR Check
name: CI
on:
- pull_request
pull_request:
push:
branches:
- master
jobs:
check-and-test:
@@ -10,6 +13,6 @@ jobs:
- uses: actions/setup-go@main
with:
go-version-file: 'go.mod'
- run: go mod tidy
- run: go mod tidy
- run: go build ./...
- run: go test -race -v -shuffle=on ./...
- run: go test -race -v -shuffle=on ./...
+1 -1
View File
@@ -1,6 +1,6 @@
module teleport
go 1.23.5
go 1.26.0
require (
github.com/miekg/dns v1.1.68
+27 -18
View File
@@ -27,28 +27,24 @@ type Config struct {
Compress bool `yaml:"compress"` // compress backup files
}
// Init initializes the global logger with the given configuration
func Init(config Config) error {
mu.Lock()
defer mu.Unlock()
Log = logrus.New()
func newLogger(config Config) (*logrus.Logger, error) {
l := logrus.New()
// Set log level
level, err := logrus.ParseLevel(config.Level)
if err != nil {
level = logrus.InfoLevel
}
Log.SetLevel(level)
l.SetLevel(level)
// Set log format with sanitization
switch config.Format {
case "json":
Log.SetFormatter(&SanitizedJSONFormatter{
l.SetFormatter(&SanitizedJSONFormatter{
TimestampFormat: "2006-01-02 15:04:05",
})
default:
Log.SetFormatter(&SanitizedTextFormatter{
l.SetFormatter(&SanitizedTextFormatter{
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
@@ -59,36 +55,49 @@ func Init(config Config) error {
// Ensure directory exists
dir := filepath.Dir(config.File)
if err := os.MkdirAll(dir, 0755); err != nil {
return err
return nil, err
}
// Open log file with secure permissions (owner read/write only)
file, err := os.OpenFile(config.File, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
if err != nil {
return err
return nil, err
}
// Set output to both file and stdout
Log.SetOutput(io.MultiWriter(file, os.Stdout))
l.SetOutput(io.MultiWriter(file, os.Stdout))
} else {
Log.SetOutput(os.Stdout)
l.SetOutput(os.Stdout)
}
return l, nil
}
// Init initializes the global logger with the given configuration
func Init(config Config) error {
l, err := newLogger(config)
if err != nil {
return err
}
mu.Lock()
Log = l
mu.Unlock()
return nil
}
// GetLogger returns the global logger instance
func GetLogger() *logrus.Logger {
mu.RLock()
if Log != nil {
mu.RUnlock()
return Log
}
l := Log
mu.RUnlock()
if l != nil {
return l
}
// Initialize with default config if not already initialized
once.Do(func() {
Init(Config{
_ = Init(Config{
Level: "info",
Format: "text",
File: "",