Browse Source

better logging

Nils 3 years ago
  1. 20


@ -269,7 +269,7 @@ class NSMClient(object):
global logger
logger = logging.getLogger(prettyName)"import")"import")
if loggingLevel == "info" or loggingLevel == 20:
logging.basicConfig(level=logging.INFO) #development"Starting PyNSM2 Client with logging level INFO. Switch to 'error' for a release!") #the NSM name is not ready yet so we just use the pretty name
@ -279,7 +279,6 @@ class NSMClient(object):
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.
self.supportsSaveStatus = supportsSaveStatus
@ -303,8 +302,7 @@ 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.
@ -325,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.
assert self.serverFeatures, self.serverFeatures
assert self.sessionName, self.sessionName
assert self.ourPath, self.ourPath
@ -335,7 +335,9 @@ class NSMClient(object):
#After this point the host must include self.reactToMessage in its event loop
#We assume we are save at startup.
self.announceSaveStatus(isClean = True)
self.announceSaveStatus(isClean = True)"NSMClient client init complete. Going into listening mode.")
def reactToMessage(self):
@ -419,6 +421,8 @@ class NSMClient(object):
return """Sending our NSM-announce message")
announce = _OutgoingMessage("/nsm/server/announce")
announce.add_arg(self.prettyName) #s:application_name
announce.add_arg(buildClientFeaturesString()) #s:capabilities
@ -491,10 +495,12 @@ class NSMClient(object):
self.announceSaveStatus(isClean = True)
def _sessionIsLoadedCallback(self, msg):
def _sessionIsLoadedCallback(self, msg):
if self.sessionIsLoadedCallback:"Telling our client that the session has finished loading")"Received 'Session is Loaded'. Our client supports it. Forwarding message...")
else:"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