Portable mode moves debug.log

This commit is contained in:
Jonathan Warren 2013-07-15 15:45:03 -04:00
parent 558dcf8550
commit 08694ecc38
3 changed files with 64 additions and 37 deletions

View File

@ -29,6 +29,8 @@ import os
from pyelliptic.openssl import OpenSSL
import pickle
import platform
import debug
from debug import logger
try:
from PyQt4 import QtCore, QtGui
@ -1874,7 +1876,14 @@ class MyForm(QtGui.QMainWindow):
shared.knownNodesLock.release()
os.remove(shared.appdata + 'keys.dat')
os.remove(shared.appdata + 'knownnodes.dat')
previousAppdataLocation = shared.appdata
shared.appdata = ''
debug.restartLoggingInUpdatedAppdataLocation()
try:
os.remove(previousAppdataLocation + 'debug.log')
os.remove(previousAppdataLocation + 'debug.log.1')
except:
pass
if shared.appdata == '' and not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we ARE using portable mode now but the user selected that we shouldn't...
shared.appdata = shared.lookupAppdataFolder()
@ -1894,6 +1903,12 @@ class MyForm(QtGui.QMainWindow):
shared.knownNodesLock.release()
os.remove('keys.dat')
os.remove('knownnodes.dat')
debug.restartLoggingInUpdatedAppdataLocation()
try:
os.remove('debug.log')
os.remove('debug.log.1')
except:
pass
def click_radioButtonBlacklist(self):
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':

View File

@ -5,6 +5,7 @@ import time
import shutil # used for moving the messages.dat file
import sys
import os
from debug import logger
# This thread exists because SQLITE3 is so un-threadsafe that we must
# submit queries to it and it puts results back in a different queue. They

View File

@ -23,6 +23,7 @@ import shared
# TODO(xj9): Get from a config file.
log_level = 'DEBUG'
def configureLogging():
logging.config.dictConfig({
'version': 1,
'formatters': {
@ -67,4 +68,14 @@ logging.config.dictConfig({
})
# TODO (xj9): Get from a config file.
#logger = logging.getLogger('console_only')
configureLogging()
logger = logging.getLogger('both')
def restartLoggingInUpdatedAppdataLocation():
global logger
for i in list(logger.handlers):
logger.removeHandler(i)
i.flush()
i.close()
configureLogging()
logger = logging.getLogger('both')