change a few prints to logs

This commit is contained in:
sqlcoder 2010-02-06 18:06:21 +00:00
parent 1e832952dd
commit 49e4a7db69

View File

@ -70,16 +70,15 @@ class HUD_main(object):
def __init__(self, db_name = 'fpdb'): def __init__(self, db_name = 'fpdb'):
try: try:
print "HUD_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 = Configuration.get_logger("logging.conf", "hud", log_dir=self.config.dir_log)
log.info("HUD_main starting") log.info("HUD_main starting: using db name = %s" % (db_name))
log.info("Using db name = %s" % (db_name))
if not options.errorsToConsole: if not options.errorsToConsole:
fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt') fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt')
print "Note: error output is being diverted to\n"+fileName \ print "Note: error output is being diverted to:\n"+fileName \
+ "\nAny major error will be reported there _only_.\n" + "\nAny major error will be reported there _only_.\n"
errorFile = open(fileName, 'w', 0) errorFile = open(fileName, 'w', 0)
sys.stderr = errorFile sys.stderr = errorFile
@ -139,8 +138,8 @@ 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:
print "*** Exception in HUD_main::idle_func() *** " log.error( "*** Exception in HUD_main::idle_func() *** " )
traceback.print_stack() log.error( traceback.format_stack() )
finally: finally:
gtk.gdk.threads_leave() gtk.gdk.threads_leave()
return False return False
@ -247,8 +246,8 @@ class HUD_main(object):
try: try:
self.hud_dict[temp_key].stat_dict = stat_dict self.hud_dict[temp_key].stat_dict = stat_dict
except KeyError: # HUD instance has been killed off, key is stale except KeyError: # HUD instance has been killed off, key is stale
sys.stderr.write('hud_dict[%s] was not found\n' % temp_key) log.error('hud_dict[%s] was not found\n' % temp_key)
sys.stderr.write('will not send hand\n') log.error('will not send hand\n')
# Unlocks table, copied from end of function # Unlocks table, copied from end of function
self.db_connection.connection.rollback() self.db_connection.connection.rollback()
return return
@ -281,7 +280,7 @@ class HUD_main(object):
# If no client window is found on the screen, complain and continue # If no client window is found on the screen, complain and continue
if type == "tour": if type == "tour":
table_name = "%s %s" % (tour_number, tab_number) table_name = "%s %s" % (tour_number, tab_number)
# sys.stderr.write("HUD create: table name "+table_name+" not found, skipping.\n") # log.error("HUD create: table name "+table_name+" not found, skipping.\n")
log.error("HUD create: table name %s not found, skipping." % table_name) log.error("HUD create: table name %s not found, skipping." % table_name)
else: else:
tablewindow.max = max tablewindow.max = max
@ -290,7 +289,7 @@ class HUD_main(object):
if hasattr(tablewindow, 'number'): if hasattr(tablewindow, 'number'):
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards) self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards)
else: else:
sys.stderr.write('Table "%s" no longer exists\n' % table_name) log.error('Table "%s" no longer exists\n' % table_name)
t6 = time.time() t6 = time.time()
log.info("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)" log.info("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)"