Improved p.Debug.Println, left out the DEBUG: prefix as couldn't figure out how to add the suffix yet. Closes gh-17

This commit is contained in:
Jarno Rankinen 2023-03-03 09:11:39 +02:00
parent dbbc22809e
commit 8e8b51f8b9
1 changed files with 4 additions and 12 deletions

View File

@ -91,9 +91,9 @@ var (
mutexcoils = []uint16{1, 2, 3, 6, 7, 10, 40} mutexcoils = []uint16{1, 2, 3, 6, 7, 10, 40}
) )
func (logger *PingvinLogger) Println(msg string) { func (logger *PingvinLogger) Println(msg ...any) {
if logger.dbg { if logger.dbg {
log.Println("DEBUG: ", msg) log.Println(msg...)
} }
} }
@ -409,9 +409,7 @@ func (p *PingvinKL) WriteCoils(startaddr uint16, quantity uint16, vals []bool) e
// -> 0b10100010 // -> 0b10100010
bits[i/8] &= ^(1 << uint(i%8)) bits[i/8] &= ^(1 << uint(i%8))
} }
if p.Debug.dbg { p.Debug.Println("index:", i/8, "value:", bits[i/8], "shift:", i%8)
log.Println("index:", i/8, "value:", bits[i/8], "shift:", i%8)
}
} }
log.Println(bits) log.Println(bits)
client := modbus.NewClient(handler) client := modbus.NewClient(handler)
@ -505,14 +503,8 @@ func parseStatus(value int) string {
func (p *PingvinKL) Monitor(interval int) { func (p *PingvinKL) Monitor(interval int) {
for { for {
time.Sleep(time.Duration(interval) * time.Second) time.Sleep(time.Duration(interval) * time.Second)
if p.Debug.dbg { p.Debug.Println("Updating values")
log.Println("DEBUG: Updating values")
}
p.Update() p.Update()
if p.Debug.dbg {
log.Println("DEBUG: coils:", p.Coils)
log.Println("DEBUG: registers:", p.Registers)
}
} }
} }