Migrate all log.Printf/Println calls across the codebase to use the new pkg/logging structured logging package. This provides consistent log formatting with levels, timestamps, and structured key-value fields. Files updated: - pkg/mining/manager.go, service.go, events.go, miner.go - pkg/mining/xmrig_start.go, ttminer_start.go - pkg/mining/syslog_unix.go, syslog_windows.go - pkg/database/hashrate.go - pkg/node/worker.go, transport.go, peer.go 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
843 B
Go
33 lines
843 B
Go
//go:build !windows
|
|
|
|
package mining
|
|
|
|
import (
|
|
"log/syslog"
|
|
|
|
"github.com/Snider/Mining/pkg/logging"
|
|
)
|
|
|
|
var syslogWriter *syslog.Writer
|
|
|
|
func init() {
|
|
// Initialize syslog writer globally.
|
|
// LOG_NOTICE is for normal but significant condition.
|
|
// LOG_DAEMON is for system daemons.
|
|
// "mining-service" is the tag for the log messages.
|
|
var err error
|
|
syslogWriter, err = syslog.New(syslog.LOG_NOTICE|syslog.LOG_DAEMON, "mining-service")
|
|
if err != nil {
|
|
logging.Warn("failed to connect to syslog, syslog logging disabled", logging.Fields{"error": err})
|
|
syslogWriter = nil // Ensure it's nil on failure
|
|
}
|
|
}
|
|
|
|
// logToSyslog sends a message to syslog if available, otherwise falls back to standard log.
|
|
func logToSyslog(message string) {
|
|
if syslogWriter != nil {
|
|
_ = syslogWriter.Notice(message)
|
|
} else {
|
|
logging.Info(message)
|
|
}
|
|
}
|