tidy up logging so that log isn't created in /fpdb/log/ unless it is being used
This commit is contained in:
parent
7e5f63ce89
commit
86330e536a
7
pyfpdb/Configuration.py
Normal file → Executable file
7
pyfpdb/Configuration.py
Normal file → Executable file
|
@ -38,6 +38,10 @@ from xml.dom.minidom import Node
|
||||||
import logging, logging.config
|
import logging, logging.config
|
||||||
import ConfigParser
|
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
|
# Functions for finding config files and setting up logging
|
||||||
# Also used in other modules that use logging.
|
# Also used in other modules that use logging.
|
||||||
|
@ -138,8 +142,6 @@ def check_dir(path, create = True):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# find a logging.conf file and set up logging
|
|
||||||
log = get_logger("logging.conf", "config")
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# application wide consts
|
# application wide consts
|
||||||
|
@ -458,6 +460,7 @@ class Config:
|
||||||
self.dir_config = os.path.dirname(self.file)
|
self.dir_config = os.path.dirname(self.file)
|
||||||
self.dir_log = os.path.join(self.dir_config, 'log')
|
self.dir_log = os.path.join(self.dir_config, 'log')
|
||||||
self.dir_database = os.path.join(self.dir_config, 'database')
|
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)
|
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
|
# Parse even if there was no real config file found and we are using the example
|
||||||
|
|
|
@ -41,6 +41,10 @@ import Queue
|
||||||
import codecs
|
import codecs
|
||||||
import math
|
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
|
# pyGTK modules
|
||||||
|
|
||||||
|
@ -52,7 +56,6 @@ import Tourney
|
||||||
import Charset
|
import Charset
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
import Configuration
|
import Configuration
|
||||||
log = Configuration.get_logger("logging.conf","db")
|
|
||||||
|
|
||||||
|
|
||||||
# Other library modules
|
# Other library modules
|
||||||
|
@ -225,7 +228,7 @@ class Database:
|
||||||
|
|
||||||
def __init__(self, c, sql = None):
|
def __init__(self, c, sql = None):
|
||||||
log = Configuration.get_logger("logging.conf", "db", log_dir=c.dir_log)
|
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.config = c
|
||||||
self.__connected = False
|
self.__connected = False
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
|
|
|
@ -26,13 +26,13 @@ import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import pango
|
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
|
MAX_LINES = 100000 # max lines to display in window
|
||||||
EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file
|
EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file
|
||||||
logfile = 'logging.out' # name of logfile
|
|
||||||
|
|
||||||
class GuiLogView:
|
class GuiLogView:
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class GuiLogView:
|
||||||
self.main_window = mainwin
|
self.main_window = mainwin
|
||||||
self.closeq = closeq
|
self.closeq = closeq
|
||||||
|
|
||||||
|
self.logfile = self.config.log_file # name of logfile
|
||||||
self.dia = gtk.Dialog(title="Log Messages"
|
self.dia = gtk.Dialog(title="Log Messages"
|
||||||
,parent=None
|
,parent=None
|
||||||
,flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
,flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||||
|
@ -117,10 +118,10 @@ class GuiLogView:
|
||||||
self.listcols = []
|
self.listcols = []
|
||||||
|
|
||||||
# guesstimate number of lines in file
|
# guesstimate number of lines in file
|
||||||
if os.path.exists(logfile):
|
if os.path.exists(self.logfile):
|
||||||
stat_info = os.stat(logfile)
|
stat_info = os.stat(self.logfile)
|
||||||
lines = stat_info.st_size / EST_CHARS_PER_LINE
|
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
|
# set startline to line number to start display from
|
||||||
startline = 0
|
startline = 0
|
||||||
|
@ -129,7 +130,7 @@ class GuiLogView:
|
||||||
startline = lines - MAX_LINES
|
startline = lines - MAX_LINES
|
||||||
|
|
||||||
l = 0
|
l = 0
|
||||||
for line in open(logfile):
|
for line in open(self.logfile):
|
||||||
# eg line:
|
# eg line:
|
||||||
# 2009-12-02 15:23:21,716 - config DEBUG config logger initialised
|
# 2009-12-02 15:23:21,716 - config DEBUG config logger initialised
|
||||||
l = l + 1
|
l = l + 1
|
||||||
|
|
|
@ -117,7 +117,6 @@ import Exceptions
|
||||||
|
|
||||||
VERSION = "0.12"
|
VERSION = "0.12"
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", "fpdb")
|
|
||||||
|
|
||||||
class fpdb:
|
class fpdb:
|
||||||
def tab_clicked(self, widget, tab_name):
|
def tab_clicked(self, widget, tab_name):
|
||||||
|
@ -696,6 +695,7 @@ class fpdb:
|
||||||
"""Loads profile from the provided path name."""
|
"""Loads profile from the provided path name."""
|
||||||
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||||
log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log)
|
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:
|
if self.config.example_copy:
|
||||||
self.info_box( "Config file"
|
self.info_box( "Config file"
|
||||||
, "has been created at:\n%s.\n" % self.config.file
|
, "has been created at:\n%s.\n" % self.config.file
|
||||||
|
|
5
pyfpdb/fpdb_import.py
Normal file → Executable file
5
pyfpdb/fpdb_import.py
Normal file → Executable file
|
@ -30,6 +30,10 @@ import Queue
|
||||||
from collections import deque # using Queue for now
|
from collections import deque # using Queue for now
|
||||||
import threading
|
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 pygtk
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
|
@ -39,7 +43,6 @@ import Database
|
||||||
import Configuration
|
import Configuration
|
||||||
import Exceptions
|
import Exceptions
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf", "importer")
|
|
||||||
|
|
||||||
# database interface modules
|
# database interface modules
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user