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>
33 lines
868 B
Go
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)
|
|
}
|
|
}
|