From 3288cea61c7b7338ac996069be367af71bdbcd0f Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 4 Mar 2020 23:04:01 +0100 Subject: Don't flood Messenger bridge logs to stderr by default --- account.go | 1 + connector/external/config.go | 4 +++- connector/external/external.go | 5 ++--- external/messenger.py | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/account.go b/account.go index e6a2e3d..da6e854 100644 --- a/account.go +++ b/account.go @@ -188,6 +188,7 @@ func (a *Account) ezbrMessagef(format string, args ...interface{}) { } func (a *Account) connect() { + log.Printf("Connecting %s %s (%s)", a.MatrixUser, a.AccountName, a.Protocol) ezbrSystemSendf(a.MatrixUser, "Connecting to account %s (%s)", a.AccountName, a.Protocol) err := a.Conn.Configure(a.Config) diff --git a/connector/external/config.go b/connector/external/config.go index bf2a5f8..03e1feb 100644 --- a/connector/external/config.go +++ b/connector/external/config.go @@ -1,6 +1,8 @@ package external import ( + "os" + . "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" ) @@ -30,7 +32,7 @@ func init() { return &External{ protocol: MESSENGER_PROTOCOL, command: "./external/messenger.py", - debug: true, + debug: (os.Getenv("EASYBRIDGE_MESSENGER_DEBUG") == "true"), } }, Schema: ConfigSchema{ diff --git a/connector/external/external.go b/connector/external/external.go index 553c657..d4a6caf 100644 --- a/connector/external/external.go +++ b/connector/external/external.go @@ -152,12 +152,11 @@ func (ext *External) setupProc(generation int) error { if ext.debug { recv = io.TeeReader(recv, os.Stderr) send = io.MultiWriter(send, os.Stderr) + ext.proc.Stderr = os.Stderr } ext.sendJson = json.NewEncoder(send) - ext.proc.Stderr = os.Stderr - err = ext.proc.Start() if err != nil { return err @@ -250,7 +249,7 @@ func (ext *External) recvLoop(from io.Reader, generation int) { break } - log.Debugf("GOT MESSAGE: %#v %#v", msg, msg.Data) + log.Tracef("GOT MESSAGE: %#v %#v", msg, msg.Data) if strings.HasPrefix(msg.MsgType, "rep_") { func() { ext.lock.Lock() diff --git a/external/messenger.py b/external/messenger.py index 684f7a0..b5dd2d3 100755 --- a/external/messenger.py +++ b/external/messenger.py @@ -234,6 +234,8 @@ class MessengerBridge: self.client.setBridge(self) + self.my_user_id = self.getUserIdFromUid(self.client.uid) + threads = self.client.fetchThreadList() # ensure we have a correct mapping for bridged user IDs to fb uids # (this should be fast) @@ -252,8 +254,7 @@ class MessengerBridge: self.close() elif ty == GET_USER: - userId = self.getUserIdFromUid(self.client.uid) - return {"_type": REP_OK, "user": userId} + return {"_type": REP_OK, "user": self.my_user_id} elif ty == JOIN: self.ensure_i_joined(cmd["room"]) -- cgit v1.2.3