Add debug logging
This commit is contained in:
parent
6311d6fbac
commit
dcc2fb8bdc
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
.vscode
|
||||
*debug*
|
||||
goldwarden*
|
@ -52,7 +52,7 @@ func readMessageLength(msg []byte) int {
|
||||
|
||||
func send(msg SendMessage) {
|
||||
byteMsg := dataToBytes(msg)
|
||||
logging.Debugf("Sending message: " + string(byteMsg))
|
||||
logging.Debugf("[SENSITIVE] Sending message: " + string(byteMsg))
|
||||
writeMessageLength(byteMsg)
|
||||
|
||||
var msgBuf bytes.Buffer
|
||||
|
32
browserbiometrics/logging/debuglogger.go
Normal file
32
browserbiometrics/logging/debuglogger.go
Normal file
@ -0,0 +1,32 @@
|
||||
//go:build !nooplogging
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func writeLog(level string, format string, args ...interface{}) {
|
||||
file, _ := os.OpenFile("/tmp/DELETE_ME.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
// log with date and time
|
||||
file.WriteString("[" + level + "] ")
|
||||
file.WriteString(time.Now().Format("2006-01-02 15:04:05") + " ")
|
||||
file.WriteString(fmt.Sprintf(format, args...))
|
||||
file.WriteString("\n")
|
||||
file.Close()
|
||||
}
|
||||
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
writeLog("DEBUG", format, args...)
|
||||
}
|
||||
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
writeLog("ERROR", format, args...)
|
||||
}
|
||||
|
||||
func Panicf(format string, args ...interface{}) {
|
||||
writeLog("PANIC", format, args...)
|
||||
panic("")
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//go:build !logging
|
||||
//go:build nooplogging
|
||||
|
||||
package logging
|
||||
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/quexten/goldwarden/browserbiometrics/logging"
|
||||
)
|
||||
|
||||
const appID = "com.quexten.bw-bio-handler"
|
||||
@ -25,7 +27,9 @@ func Main() {
|
||||
return
|
||||
}
|
||||
|
||||
logging.Debugf("Starting browserbiometrics")
|
||||
transportKey = generateTransportKey()
|
||||
logging.Debugf("Generated transport key")
|
||||
|
||||
setupCommunication()
|
||||
readLoop()
|
||||
|
@ -18,11 +18,13 @@ func readLoop() {
|
||||
lengthBytes := make([]byte, 4)
|
||||
lengthNum := int(0)
|
||||
|
||||
logging.Debugf("Sending connected message")
|
||||
send(SendMessage{
|
||||
Command: "connected",
|
||||
AppID: appID,
|
||||
})
|
||||
|
||||
logging.Debugf("Starting read loop")
|
||||
for b, err := s.Read(lengthBytes); b > 0 && err == nil; b, err = s.Read(lengthBytes) {
|
||||
lengthNum = readMessageLength(lengthBytes)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user