Don't propagate loggers; add some logging.
This commit is contained in:
parent
eed8c66512
commit
2e2db97250
|
@ -48,12 +48,15 @@ logging.config.dictConfig({
|
||||||
'loggers': {
|
'loggers': {
|
||||||
'console_only': {
|
'console_only': {
|
||||||
'handlers': ['console'],
|
'handlers': ['console'],
|
||||||
|
'propagate' : 0
|
||||||
},
|
},
|
||||||
'file_only': {
|
'file_only': {
|
||||||
'handlers': ['file'],
|
'handlers': ['file'],
|
||||||
|
'propagate' : 0
|
||||||
},
|
},
|
||||||
'both': {
|
'both': {
|
||||||
'handlers': ['console', 'file'],
|
'handlers': ['console', 'file'],
|
||||||
|
'propagate' : 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'root': {
|
'root': {
|
||||||
|
|
|
@ -118,7 +118,8 @@ def lookupAppdataFolder():
|
||||||
if "HOME" in environ:
|
if "HOME" in environ:
|
||||||
dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
||||||
else:
|
else:
|
||||||
print 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.'
|
logger.critical('Could not find home folder, please report this message and your '
|
||||||
|
'OS X version to the BitMessage Github.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
elif 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
|
@ -129,13 +130,14 @@ def lookupAppdataFolder():
|
||||||
dataFolder = path.join(environ["XDG_CONFIG_HOME"], APPNAME)
|
dataFolder = path.join(environ["XDG_CONFIG_HOME"], APPNAME)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
dataFolder = path.join(environ["HOME"], ".config", APPNAME)
|
dataFolder = path.join(environ["HOME"], ".config", APPNAME)
|
||||||
|
|
||||||
# Migrate existing data to the proper location if this is an existing install
|
# Migrate existing data to the proper location if this is an existing install
|
||||||
try:
|
if not os.path.exists(dataFolder):
|
||||||
print "Moving data folder to ~/.config/%s" % APPNAME
|
try:
|
||||||
move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder)
|
logger.info("Moving data folder to ~/.config/%s" % APPNAME)
|
||||||
dataFolder = dataFolder + '/'
|
move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder)
|
||||||
except IOError:
|
except IOError:
|
||||||
dataFolder = dataFolder + '/'
|
dataFolder = dataFolder + '/'
|
||||||
return dataFolder
|
return dataFolder
|
||||||
|
|
||||||
def isAddressInMyAddressBook(address):
|
def isAddressInMyAddressBook(address):
|
||||||
|
@ -200,9 +202,7 @@ def decodeWalletImportFormat(WIFstring):
|
||||||
|
|
||||||
|
|
||||||
def reloadMyAddressHashes():
|
def reloadMyAddressHashes():
|
||||||
printLock.acquire()
|
logger.debug('reloading keys from keys.dat file')
|
||||||
print 'reloading keys from keys.dat file'
|
|
||||||
printLock.release()
|
|
||||||
myECCryptorObjects.clear()
|
myECCryptorObjects.clear()
|
||||||
myAddressesByHash.clear()
|
myAddressesByHash.clear()
|
||||||
#myPrivateKeys.clear()
|
#myPrivateKeys.clear()
|
||||||
|
@ -221,9 +221,7 @@ def reloadMyAddressHashes():
|
||||||
sys.stderr.write('Error in reloadMyAddressHashes: Can\'t handle address versions other than 2 or 3.\n')
|
sys.stderr.write('Error in reloadMyAddressHashes: Can\'t handle address versions other than 2 or 3.\n')
|
||||||
|
|
||||||
def reloadBroadcastSendersForWhichImWatching():
|
def reloadBroadcastSendersForWhichImWatching():
|
||||||
printLock.acquire()
|
logger.debug('reloading subscriptions...')
|
||||||
print 'reloading subscriptions...'
|
|
||||||
printLock.release()
|
|
||||||
broadcastSendersForWhichImWatching.clear()
|
broadcastSendersForWhichImWatching.clear()
|
||||||
MyECSubscriptionCryptorObjects.clear()
|
MyECSubscriptionCryptorObjects.clear()
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
|
@ -246,46 +244,43 @@ def doCleanShutdown():
|
||||||
knownNodesLock.acquire()
|
knownNodesLock.acquire()
|
||||||
UISignalQueue.put(('updateStatusBar','Saving the knownNodes list of peers to disk...'))
|
UISignalQueue.put(('updateStatusBar','Saving the knownNodes list of peers to disk...'))
|
||||||
output = open(appdata + 'knownnodes.dat', 'wb')
|
output = open(appdata + 'knownnodes.dat', 'wb')
|
||||||
print 'finished opening knownnodes.dat. Now pickle.dump'
|
logger.info('finished opening knownnodes.dat. Now pickle.dump')
|
||||||
pickle.dump(knownNodes, output)
|
pickle.dump(knownNodes, output)
|
||||||
print 'Completed pickle.dump. Closing output...'
|
logger.info('Completed pickle.dump. Closing output...')
|
||||||
output.close()
|
output.close()
|
||||||
knownNodesLock.release()
|
knownNodesLock.release()
|
||||||
printLock.acquire()
|
logger.info('Finished closing knownnodes.dat output file.')
|
||||||
print 'Finished closing knownnodes.dat output file.'
|
|
||||||
printLock.release()
|
|
||||||
UISignalQueue.put(('updateStatusBar','Done saving the knownNodes list of peers to disk.'))
|
UISignalQueue.put(('updateStatusBar','Done saving the knownNodes list of peers to disk.'))
|
||||||
|
|
||||||
broadcastToSendDataQueues((0, 'shutdown', 'all'))
|
broadcastToSendDataQueues((0, 'shutdown', 'all'))
|
||||||
|
|
||||||
printLock.acquire()
|
logger.info('Flushing inventory in memory out to disk...')
|
||||||
print 'Flushing inventory in memory out to disk...'
|
UISignalQueue.put(('updateStatusBar','Flushing inventory in memory out to disk. '
|
||||||
printLock.release()
|
'This should normally only take a second...'))
|
||||||
UISignalQueue.put(('updateStatusBar','Flushing inventory in memory out to disk. This should normally only take a second...'))
|
|
||||||
flushInventory()
|
flushInventory()
|
||||||
|
|
||||||
#This one last useless query will guarantee that the previous flush committed before we close the program.
|
# This one last useless query will guarantee that the previous flush committed before we close
|
||||||
|
# the program.
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
sqlSubmitQueue.put('SELECT address FROM subscriptions')
|
sqlSubmitQueue.put('SELECT address FROM subscriptions')
|
||||||
sqlSubmitQueue.put('')
|
sqlSubmitQueue.put('')
|
||||||
sqlReturnQueue.get()
|
sqlReturnQueue.get()
|
||||||
sqlSubmitQueue.put('exit')
|
sqlSubmitQueue.put('exit')
|
||||||
sqlLock.release()
|
sqlLock.release()
|
||||||
printLock.acquire()
|
logger.info('Finished flushing inventory.')
|
||||||
print 'Finished flushing inventory.'
|
# Wait long enough to guarantee that any running proof of work worker threads will check the
|
||||||
printLock.release()
|
# shutdown variable and exit. If the main thread closes before they do then they won't stop.
|
||||||
|
time.sleep(.25)
|
||||||
time.sleep(.25) #Wait long enough to guarantee that any running proof of work worker threads will check the shutdown variable and exit. If the main thread closes before they do then they won't stop.
|
|
||||||
|
|
||||||
if safeConfigGetBoolean('bitmessagesettings','daemon'):
|
if safeConfigGetBoolean('bitmessagesettings','daemon'):
|
||||||
printLock.acquire()
|
logger.info('Clean shutdown complete.')
|
||||||
print 'Done.'
|
|
||||||
printLock.release()
|
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
#When you want to command a sendDataThread to do something, like shutdown or send some data, this function puts your data into the queues for each of the sendDataThreads. The sendDataThreads are responsible for putting their queue into (and out of) the sendDataQueues list.
|
# When you want to command a sendDataThread to do something, like shutdown or send some data, this
|
||||||
|
# function puts your data into the queues for each of the sendDataThreads. The sendDataThreads are
|
||||||
|
# responsible for putting their queue into (and out of) the sendDataQueues list.
|
||||||
def broadcastToSendDataQueues(data):
|
def broadcastToSendDataQueues(data):
|
||||||
#print 'running broadcastToSendDataQueues'
|
# logger.debug('running broadcastToSendDataQueues')
|
||||||
for q in sendDataQueues:
|
for q in sendDataQueues:
|
||||||
q.put((data))
|
q.put((data))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user