tighten up logging in hud

This commit is contained in:
sqlcoder 2010-02-12 08:18:42 +00:00
parent a93562c229
commit 906c9e0bc9
2 changed files with 7 additions and 6 deletions

View File

@ -65,7 +65,7 @@ def get_exec_path():
def get_config(file_name, fallback = True): def get_config(file_name, fallback = True):
"""Looks in cwd and in self.default_config_path for a config file.""" """Looks in cwd and in self.default_config_path for a config file."""
exec_dir = get_exec_path() exec_dir = get_exec_path()
if file_name == 'logging.conf' and sys.argv[0] != 'fpdb.exe': if file_name == 'logging.conf' and not hasattr(sys, "frozen"):
config_path = os.path.join(exec_dir, 'pyfpdb', file_name) config_path = os.path.join(exec_dir, 'pyfpdb', file_name)
else: else:
config_path = os.path.join(exec_dir, file_name) config_path = os.path.join(exec_dir, file_name)

View File

@ -60,8 +60,9 @@ elif os.name == 'nt':
import Hud import Hud
# logger is set up in __init__, create temp logger here # get config and set up logger
log = Configuration.get_logger("logging.conf", config = 'hud') c = Configuration.Config(file=options.config)
log = Configuration.get_logger("logging.conf", "hud", log_dir=c.dir_log, log_file='HUD-log.txt')
class HUD_main(object): class HUD_main(object):
@ -71,8 +72,7 @@ class HUD_main(object):
def __init__(self, db_name = 'fpdb'): def __init__(self, db_name = 'fpdb'):
print "\nHUD_main: starting ..." print "\nHUD_main: starting ..."
self.db_name = db_name self.db_name = db_name
self.config = Configuration.Config(file=options.config, dbname=db_name) self.config = Configuration.Config(file=options.config, dbname = db_name)
log = Configuration.get_logger("logging.conf", "hud", log_dir=self.config.dir_log, log_file='HUD-log.txt')
print "Logfile is " + os.path.join(self.config.dir_log, 'HUD-log.txt') print "Logfile is " + os.path.join(self.config.dir_log, 'HUD-log.txt')
log.info("HUD_main starting: using db name = %s" % (db_name)) log.info("HUD_main starting: using db name = %s" % (db_name))
@ -85,6 +85,7 @@ class HUD_main(object):
log.info("Any major error will be reported there _only_.") log.info("Any major error will be reported there _only_.")
errorFile = open(fileName, 'w', 0) errorFile = open(fileName, 'w', 0)
sys.stderr = errorFile sys.stderr = errorFile
sys.stderr.write("HUD_main: starting ...\n")
self.hud_dict = {} self.hud_dict = {}
self.hud_params = self.config.get_hud_ui_parameters() self.hud_params = self.config.get_hud_ui_parameters()
@ -142,7 +143,7 @@ class HUD_main(object):
self.hud_dict[table_name].update(new_hand_id, self.config) self.hud_dict[table_name].update(new_hand_id, self.config)
self.hud_dict[table_name].reposition_windows() self.hud_dict[table_name].reposition_windows()
except: except:
log.error( "*** Exception in HUD_main::idle_func() *** " ) log.error( "*** Exception in HUD_main::idle_func() *** " + str(sys.exc_info()) )
for e in traceback.format_tb(sys.exc_info()[2]): for e in traceback.format_tb(sys.exc_info()[2]):
log.error(e) log.error(e)
finally: finally: