mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-20 02:04:15 +01:00
refactor: use structured logging
This commit is contained in:
@@ -38,7 +38,7 @@ func rebindUsb(udc string, ignoreUnbindError bool) error {
|
||||
}
|
||||
|
||||
func (u *UsbGadget) rebindUsb(ignoreUnbindError bool) error {
|
||||
u.log.Infof("rebinding USB gadget to UDC %s", u.udc)
|
||||
u.log.Info().Str("udc", u.udc).Msg("rebinding USB gadget to UDC")
|
||||
return rebindUsb(u.udc, ignoreUnbindError)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (u *UsbGadget) RebindUsb(ignoreUnbindError bool) error {
|
||||
func (u *UsbGadget) writeUDC() error {
|
||||
path := path.Join(u.kvmGadgetPath, "UDC")
|
||||
|
||||
u.log.Tracef("writing UDC %s to %s", u.udc, path)
|
||||
u.log.Trace().Str("udc", u.udc).Str("path", path).Msg("writing UDC")
|
||||
err := u.writeIfDifferent(path, []byte(u.udc), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write UDC: %w", err)
|
||||
@@ -70,7 +70,7 @@ func (u *UsbGadget) GetUsbState() (state string) {
|
||||
if os.IsNotExist(err) {
|
||||
return "not attached"
|
||||
} else {
|
||||
u.log.Tracef("failed to read usb state: %v", err)
|
||||
u.log.Trace().Err(err).Msg("failed to read usb state")
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user