chore: update logging

This commit is contained in:
Siyuan Miao
2025-04-11 12:55:36 +02:00
parent 924b55059f
commit 0ba7902f82
13 changed files with 246 additions and 105 deletions

6
wol.go
View File

@@ -11,7 +11,7 @@ func rpcSendWOLMagicPacket(macAddress string) error {
// Parse the MAC address
mac, err := net.ParseMAC(macAddress)
if err != nil {
return ErrorfL(&wolLogger, "invalid MAC address", err)
return ErrorfL(wolLogger, "invalid MAC address", err)
}
// Create the magic packet
@@ -20,14 +20,14 @@ func rpcSendWOLMagicPacket(macAddress string) error {
// Set up UDP connection
conn, err := net.Dial("udp", "255.255.255.255:9")
if err != nil {
return ErrorfL(&wolLogger, "failed to establish UDP connection", err)
return ErrorfL(wolLogger, "failed to establish UDP connection", err)
}
defer conn.Close()
// Send the packet
_, err = conn.Write(packet)
if err != nil {
return ErrorfL(&wolLogger, "failed to send WOL packet", err)
return ErrorfL(wolLogger, "failed to send WOL packet", err)
}
wolLogger.Info().Str("mac", macAddress).Msg("WOL packet sent")