[internal/logging] add logging lib
This commit is contained in:
@@ -20,7 +20,7 @@ func isEthernetConnected(deviceName string) bool {
|
||||
content, err := os.ReadFile(fmt.Sprintf("/sys/class/net/%s/operstate", deviceName))
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
internal.LogDoc(EthernetDisconnect{}).Errorf("Cant read devices operstate. Check the deviceName. error: %s", err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package triggers
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"unknown.com/gokill/actions"
|
||||
@@ -14,10 +13,10 @@ type TimeOut struct {
|
||||
}
|
||||
|
||||
func (t TimeOut) Listen() {
|
||||
fmt.Println("TimeOut listens")
|
||||
fmt.Println(t.Duration)
|
||||
internal.LogDoc(t).Info("TimeOut listens")
|
||||
internal.LogDoc(t).Infof("%d", t.Duration)
|
||||
time.Sleep(time.Duration(t.Duration) * time.Second)
|
||||
fmt.Println("TimeOut fires")
|
||||
internal.LogDoc(t).Notice("TimeOut fires")
|
||||
actions.Fire(t.action)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package triggers
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -35,8 +34,8 @@ func (t UsbDisconnect) Listen() {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
fmt.Printf("Device %s detected.\n", t.DeviceName)
|
||||
fmt.Println("UsbDisconnect Trigger is Armed")
|
||||
internal.LogDoc(t).Infof("Device %s detected.\n", t.DeviceName)
|
||||
internal.LogDoc(t).Notice("Trigger is Armed")
|
||||
}
|
||||
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user