Mining/pkg/mining/syslog_unix.go
Claude 9e0126a935
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
ax(batch): remaining prose-to-example comment conversions
Convert final batch of prose-style comments to concrete usage examples:
- ttminer_start.go: buildArgs, addTTMinerCliArgs, isValidCLIArg,
  isValidArgValue now show realistic input/output
- logger.go: log() method shows concrete call
- syslog_unix.go: logToSyslog shows realistic message

Co-Authored-By: Charon <charon@lethean.io>
2026-04-02 18:08:24 +01:00

33 lines
868 B
Go

//go:build !windows
package mining
import (
"log/syslog"
"forge.lthn.ai/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("CryptoCurrency Miner started: xmrig") // writes to syslog LOG_NOTICE or falls back to logging.Info
func logToSyslog(message string) {
if syslogWriter != nil {
_ = syslogWriter.Notice(message)
} else {
logging.Info(message)
}
}