Browse Source

Better logging in nsmclient

master
Nils 4 years ago
parent
commit
5de6c692fb
  1. 15
      template/qtgui/nsmclient.py

15
template/qtgui/nsmclient.py

@ -276,8 +276,8 @@ class NSMClient(object):
elif loggingLevel == "error" or loggingLevel == 40:
logging.basicConfig(level=logging.ERROR) #production
else:
raise ValueError("Unknown logging level: {}. Choose 'info' or 'error'".format(loggingLevel))
logging.warning("Unknown logging level: {}. Choose 'info' or 'error'".format(loggingLevel))
logging.basicConfig(level=logging.INFO) #development
#given parameters,
self.prettyName = prettyName #keep this consistent! Settle for one name.
@ -303,7 +303,6 @@ class NSMClient(object):
#self.discardReactions = set(["/nsm/client/session_is_loaded"])
self.discardReactions = set()
#Networking and Init
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #internet, udp
self.sock.bind(('', 0)) #pick a free port on localhost.
@ -324,7 +323,9 @@ class NSMClient(object):
self.ourClientId = None # the "file extension" of ourClientNameUnderNSM
self.isVisible = None #set in announceGuiVisibility
self.saveStatus = True # true is clean. false means we need saving.
self.announceOurselves()
assert self.serverFeatures, self.serverFeatures
assert self.sessionName, self.sessionName
assert self.ourPath, self.ourPath
@ -336,6 +337,8 @@ class NSMClient(object):
#We assume we are save at startup.
self.announceSaveStatus(isClean = True)
logger.info("NSMClient client init complete. Going into listening mode.")
def reactToMessage(self):
"""This is the main loop message. It is added to the clients event loop."""
@ -418,6 +421,8 @@ class NSMClient(object):
else:
return ""
logger.info("Sending our NSM-announce message")
announce = _OutgoingMessage("/nsm/server/announce")
announce.add_arg(self.prettyName) #s:application_name
announce.add_arg(buildClientFeaturesString()) #s:capabilities
@ -492,8 +497,10 @@ class NSMClient(object):
def _sessionIsLoadedCallback(self, msg):
if self.sessionIsLoadedCallback:
logger.info("Telling our client that the session has finished loading")
logger.info("Received 'Session is Loaded'. Our client supports it. Forwarding message...")
self.sessionIsLoadedCallback()
else:
logger.info("Received 'Session is Loaded'. Our client does not support it, which is the default. Discarding message...")
def sigtermHandler(self, signal, frame):
"""Wait for the user to quit the program

Loading…
Cancel
Save