ax(logging): replace prose comments with usage examples on global functions
AX Principle 2 — global convenience functions had comments restating the
signature ("logs a debug message using the global logger") rather than
showing concrete calls with realistic values.
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
18ac5e1c94
commit
df3a641f5f
1 changed files with 8 additions and 8 deletions
|
|
@ -228,42 +228,42 @@ func SetGlobalLevel(level Level) {
|
|||
|
||||
// Global convenience functions that use the global logger
|
||||
|
||||
// Debug logs a debug message using the global logger.
|
||||
// logging.Debug("hashrate collected", logging.Fields{"rate": 1234, "miner": "xmrig"})
|
||||
func Debug(msg string, fields ...Fields) {
|
||||
GetGlobal().Debug(msg, fields...)
|
||||
}
|
||||
|
||||
// Info logs an informational message using the global logger.
|
||||
// logging.Info("miner started", logging.Fields{"miner": "xmrig", "pool": "pool.lthn.io"})
|
||||
func Info(msg string, fields ...Fields) {
|
||||
GetGlobal().Info(msg, fields...)
|
||||
}
|
||||
|
||||
// Warn logs a warning message using the global logger.
|
||||
// logging.Warn("hashrate dropped below threshold", logging.Fields{"current": 500, "min": 1000})
|
||||
func Warn(msg string, fields ...Fields) {
|
||||
GetGlobal().Warn(msg, fields...)
|
||||
}
|
||||
|
||||
// Error logs an error message using the global logger.
|
||||
// logging.Error("miner process exited unexpectedly", logging.Fields{"code": -1})
|
||||
func Error(msg string, fields ...Fields) {
|
||||
GetGlobal().Error(msg, fields...)
|
||||
}
|
||||
|
||||
// Debugf logs a formatted debug message using the global logger.
|
||||
// logging.Debugf("collected %d hashrate points for %s", len(points), minerName)
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
GetGlobal().Debugf(format, args...)
|
||||
}
|
||||
|
||||
// Infof logs a formatted informational message using the global logger.
|
||||
// logging.Infof("miner %s started on pool %s", minerName, poolURL)
|
||||
func Infof(format string, args ...interface{}) {
|
||||
GetGlobal().Infof(format, args...)
|
||||
}
|
||||
|
||||
// Warnf logs a formatted warning message using the global logger.
|
||||
// logging.Warnf("hashrate %d H/s below minimum %d H/s", current, minimum)
|
||||
func Warnf(format string, args ...interface{}) {
|
||||
GetGlobal().Warnf(format, args...)
|
||||
}
|
||||
|
||||
// Errorf logs a formatted error message using the global logger.
|
||||
// logging.Errorf("failed to connect to pool %s: %v", poolURL, err)
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
GetGlobal().Errorf(format, args...)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue