# vim: ts=4 et sts=4 sw=4 autoindent
import logging
import logging.config
import os, sys

from sndcs_common.Win32HelperMixin import Win32HelperMixin

class Logger(Win32HelperMixin):

    def __init__(self, config_file=None):
        if config_file:
            self.config_file = config_file
        else:
            if self.main_is_frozen():
                self.config_file = os.path.join(self.get_main_dir(), "config", "logging.conf")
            elif os.name=="nt":
                self.config_file = os.path.join(sys.prefix, "etc", "sndcs", "logging.conf")
            elif os.environ.has_key("APP_BUNDLER"):
                self.config_file = "/".join( __file__.split("/")[:-2] ) + "/config/logging.conf"
            else:
                self.config_file = "/etc/sndcs/logging.conf"

        logging.config.fileConfig(self.config_file)

    def getLogger(self, name):
        return logging.getLogger(name)

logger = Logger()
