mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
Unifying logger object.
This commit is contained in:
@@ -20,7 +20,7 @@ RESET_SEQ = '\033[0m'
|
|||||||
COLOR_SEQ = '\033[1;%dm'
|
COLOR_SEQ = '\033[1;%dm'
|
||||||
BOLD_SEQ = '\033[1m'
|
BOLD_SEQ = '\033[1m'
|
||||||
|
|
||||||
LOG = logger.get_logger(__name__)
|
LOG = logger.get_logger()
|
||||||
|
|
||||||
|
|
||||||
def colorize(txt, color):
|
def colorize(txt, color):
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Base = declarative_base(metadata=Meta)
|
|||||||
Session = sessionmaker()
|
Session = sessionmaker()
|
||||||
DbFilename = None
|
DbFilename = None
|
||||||
|
|
||||||
LOG = get_logger("dbcommon")
|
LOG = get_logger()
|
||||||
|
|
||||||
|
|
||||||
def connect(filename=None):
|
def connect(filename=None):
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from pycatalog.dbcommon import Base
|
|||||||
from pycatalog.logger import get_logger
|
from pycatalog.logger import get_logger
|
||||||
|
|
||||||
|
|
||||||
LOG = get_logger(__name__)
|
LOG = get_logger()
|
||||||
|
|
||||||
tags_files = Table("tags_files", Base.metadata,
|
tags_files = Table("tags_files", Base.metadata,
|
||||||
Column("file_id", Integer, ForeignKey("files.id")),
|
Column("file_id", Integer, ForeignKey("files.id")),
|
||||||
|
|||||||
@@ -63,11 +63,10 @@ class ColoredFormatter(logging.Formatter):
|
|||||||
log_obj = None
|
log_obj = None
|
||||||
|
|
||||||
|
|
||||||
def get_logger(module_name, level='INFO', to_file=True, to_console=True):
|
def get_logger(level='INFO', to_file=True, to_console=True):
|
||||||
"""
|
"""
|
||||||
Prepare and return log object. Standard formatting is used for all logs.
|
Prepare and return log object. Standard formatting is used for all logs.
|
||||||
Arguments:
|
Arguments:
|
||||||
@module_name - String name for Logger object.
|
|
||||||
@level - Log level (as string), one of DEBUG, INFO, WARN, ERROR and
|
@level - Log level (as string), one of DEBUG, INFO, WARN, ERROR and
|
||||||
CRITICAL.
|
CRITICAL.
|
||||||
@to_file - If True, additionally stores full log in file inside
|
@to_file - If True, additionally stores full log in file inside
|
||||||
@@ -75,10 +74,13 @@ def get_logger(module_name, level='INFO', to_file=True, to_console=True):
|
|||||||
is only redirected to stderr.
|
is only redirected to stderr.
|
||||||
Returns: object of logging.Logger class
|
Returns: object of logging.Logger class
|
||||||
"""
|
"""
|
||||||
|
global log_obj
|
||||||
|
if log_obj:
|
||||||
|
return log_obj
|
||||||
|
|
||||||
path = os.path.join(os.path.expanduser("~"), ".pycatalog", "app.log")
|
path = os.path.join(os.path.expanduser("~"), ".pycatalog", "app.log")
|
||||||
|
|
||||||
log = logging.getLogger(module_name)
|
log = logging.getLogger("pycatalog")
|
||||||
log.setLevel(LEVEL[level])
|
log.setLevel(LEVEL[level])
|
||||||
|
|
||||||
if to_console:
|
if to_console:
|
||||||
@@ -104,4 +106,5 @@ def get_logger(module_name, level='INFO', to_file=True, to_console=True):
|
|||||||
dummy_handler.setFormatter(dummy_formatter)
|
dummy_handler.setFormatter(dummy_formatter)
|
||||||
log.addHandler(dummy_handler)
|
log.addHandler(dummy_handler)
|
||||||
|
|
||||||
|
log_obj = log
|
||||||
return log
|
return log
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||||
Created: 2009-04-05
|
Created: 2009-04-05
|
||||||
"""
|
"""
|
||||||
from pycatalog.logger import get_logger
|
from pycatalog import logger
|
||||||
|
|
||||||
LOG = get_logger(__name__)
|
LOG = logger.get_logger()
|
||||||
|
|
||||||
|
|
||||||
def float_to_string(float_length):
|
def float_to_string(float_length):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from pycatalog.logger import get_logger
|
|||||||
from pycatalog.video import Video
|
from pycatalog.video import Video
|
||||||
|
|
||||||
|
|
||||||
LOG = get_logger(__name__)
|
LOG = get_logger()
|
||||||
RE_FN_START = re.compile(r'(?P<fname_start>'
|
RE_FN_START = re.compile(r'(?P<fname_start>'
|
||||||
r'(\[[^\]]*\]\s)?'
|
r'(\[[^\]]*\]\s)?'
|
||||||
r'([^(]*)\s'
|
r'([^(]*)\s'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from pycatalog.misc import float_to_string
|
|||||||
from pycatalog.logger import get_logger
|
from pycatalog.logger import get_logger
|
||||||
|
|
||||||
|
|
||||||
LOG = get_logger("Video")
|
LOG = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class Video(object):
|
class Video(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user