feat: logging to debug

This commit is contained in:
Swann Martinez 2019-04-10 18:26:39 +02:00
parent f3be75ce3c
commit 26d4b152d4
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
3 changed files with 15 additions and 12 deletions

View File

@ -72,8 +72,9 @@ class RCFClient(object):
self.agent.daemon = True
self.agent.start()
def connect(self, address, port):
self.pipe.send_multipart([b"CONNECT", (address.encode() if isinstance(
def connect(self, id, address, port):
self.pipe.send_multipart([b"CONNECT", (id.encode() if isinstance(
id, str) else id), (address.encode() if isinstance(
address, str) else address), b'%d' % port])
def set(self, key):
@ -149,6 +150,7 @@ class RCFClientAgent(object):
command = msg.pop(0)
if command == b"CONNECT":
self.id = msg.pop(0)
address = msg.pop(0)
port = int(msg.pop(0))
@ -167,7 +169,7 @@ class RCFClientAgent(object):
value = helpers.dump(key)
if value:
logger.info(key,"dumped")
logger.info("{} dumped".format(key))
# Send key-value pair on to server
rcfmsg = message.RCFMessage(key=key, id=self.id, mtype="", body=value)
@ -197,8 +199,8 @@ def rcf_client_agent(ctx, pipe):
if agent.state == State.INITIAL:
server = agent.server
if agent.server:
logger.info("I: waiting for server at %s:%d...",
server.address, server.port)
logger.info("%s: waiting for server at %s:%d...",
agent.id.decode(),server.address, server.port)
server.snapshot.send(b"SNAPSHOT_REQUEST")
agent.state = State.SYNCING
server_socket = server.snapshot
@ -232,10 +234,10 @@ def rcf_client_agent(ctx, pipe):
helpers.load(rcfmsg.key,rcfmsg.body)
rcfmsg.store(agent.property_map)
action = "update" if rcfmsg.body else "delete"
logging.info("I: received from {}:{},{} {}".format(
logging.info("{}: received from {}:{},{} {}".format(agent.id,
server.address, rcfmsg.body.id, server.port, action))
else:
logger.info("IDLE")
logger.info("{} nothing to do".format(agent.id))
logger.info("exit thread")
stop = False

View File

@ -386,8 +386,8 @@ class session_join(bpy.types.Operator):
net_settings = context.scene.session_settings
# Scene setup
# if net_settings.session_mode == "CONNECT" and net_settings.clear_scene:
# clean_scene()
if net_settings.session_mode == "CONNECT" and net_settings.clear_scene:
clean_scene()
# Session setup
if net_settings.username == "DefaultUser":
@ -398,7 +398,7 @@ class session_join(bpy.types.Operator):
client_instance = client.RCFClient()
client_instance.connect("127.0.0.1",5555)
client_instance.connect(net_settings.username,"127.0.0.1",5555)
# net_settings.is_running = True

View File

@ -4,7 +4,7 @@ import time
from libs import zmq
import message
logger = logging.getLogger(__name__)
logger = logging.getLogger("Server")
logging.basicConfig(level=logging.DEBUG)
class RCFServerAgent():
@ -60,7 +60,7 @@ class RCFServerAgent():
identity = msg[0]
request = msg[1]
print("asdasd")
if request == b"SNAPSHOT_REQUEST":
pass
else:
@ -81,6 +81,7 @@ class RCFServerAgent():
# Regular update routing (Clients / Client)
elif self.collector_sock in socks:
msg = message.RCFMessage.recv(self.collector_sock)
logger.info("received object")
# Update all clients
msg.store(self.property_map)
msg.send(self.pub_sock)