diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py old mode 100644 new mode 100755 index 9c7e44b6..ec4c621e --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -38,6 +38,10 @@ from xml.dom.minidom import Node import logging, logging.config import ConfigParser +# logging has been set up in fpdb.py or HUD_main.py, use their settings: +log = logging.getLogger("config") + + ############################################################################## # Functions for finding config files and setting up logging # Also used in other modules that use logging. @@ -138,8 +142,6 @@ def check_dir(path, create = True): else: return False -# find a logging.conf file and set up logging -log = get_logger("logging.conf", "config") ######################################################################## # application wide consts @@ -458,6 +460,7 @@ class Config: self.dir_config = os.path.dirname(self.file) self.dir_log = os.path.join(self.dir_config, 'log') self.dir_database = os.path.join(self.dir_config, 'database') + self.log_file = os.path.join(self.dir_log, 'logging.out') log = get_logger("logging.conf", "config", log_dir=self.dir_log) # Parse even if there was no real config file found and we are using the example diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index a987b389..e7c01231 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -41,6 +41,10 @@ import Queue import codecs import math +import logging +# logging has been set up in fpdb.py or HUD_main.py, use their settings: +log = logging.getLogger("db") + # pyGTK modules @@ -52,7 +56,6 @@ import Tourney import Charset from Exceptions import * import Configuration -log = Configuration.get_logger("logging.conf","db") # Other library modules @@ -225,7 +228,7 @@ class Database: def __init__(self, c, sql = None): log = Configuration.get_logger("logging.conf", "db", log_dir=c.dir_log) - log.info("Creating Database instance, sql = %s" % sql) + log.debug("Creating Database instance, sql = %s" % sql) self.config = c self.__connected = False self.settings = {} diff --git a/pyfpdb/GuiLogView.py b/pyfpdb/GuiLogView.py index 29385fa0..9dcb9588 100755 --- a/pyfpdb/GuiLogView.py +++ b/pyfpdb/GuiLogView.py @@ -26,13 +26,13 @@ import gtk import gobject import pango -import Configuration +import logging +# logging has been set up in fpdb.py or HUD_main.py, use their settings: +log = logging.getLogger("logview") -log = Configuration.get_logger("logging.conf", "logview") MAX_LINES = 100000 # max lines to display in window EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file -logfile = 'logging.out' # name of logfile class GuiLogView: @@ -41,6 +41,7 @@ class GuiLogView: self.main_window = mainwin self.closeq = closeq + self.logfile = self.config.log_file # name of logfile self.dia = gtk.Dialog(title="Log Messages" ,parent=None ,flags=gtk.DIALOG_DESTROY_WITH_PARENT @@ -117,10 +118,10 @@ class GuiLogView: self.listcols = [] # guesstimate number of lines in file - if os.path.exists(logfile): - stat_info = os.stat(logfile) + if os.path.exists(self.logfile): + stat_info = os.stat(self.logfile) lines = stat_info.st_size / EST_CHARS_PER_LINE - print "logview: size =", stat_info.st_size, "lines =", lines + #print "logview: size =", stat_info.st_size, "lines =", lines # set startline to line number to start display from startline = 0 @@ -129,7 +130,7 @@ class GuiLogView: startline = lines - MAX_LINES l = 0 - for line in open(logfile): + for line in open(self.logfile): # eg line: # 2009-12-02 15:23:21,716 - config DEBUG config logger initialised l = l + 1 diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 58e0128d..c11301a9 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -117,7 +117,6 @@ import Exceptions VERSION = "0.12" -log = Configuration.get_logger("logging.conf", "fpdb") class fpdb: def tab_clicked(self, widget, tab_name): @@ -696,6 +695,7 @@ class fpdb: """Loads profile from the provided path name.""" self.config = Configuration.Config(file=options.config, dbname=options.dbname) log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log) + print "Logfile is " + os.path.join(self.config.dir_log, 'logging.out') + "\n" if self.config.example_copy: self.info_box( "Config file" , "has been created at:\n%s.\n" % self.config.file diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py old mode 100644 new mode 100755 index a02d3d99..8ba0da34 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -30,6 +30,10 @@ import Queue from collections import deque # using Queue for now import threading +import logging +# logging has been set up in fpdb.py or HUD_main.py, use their settings: +log = logging.getLogger("importer") + import pygtk import gtk @@ -39,7 +43,6 @@ import Database import Configuration import Exceptions -log = Configuration.get_logger("logging.conf", "importer") # database interface modules try: