Exemplo n.º 1
0
def _setup_logging():

    # Create logger
    logger = logging.getLogger()

    # Set the default level at info as the file level
    logger.setLevel(logging.INFO)

    # We add first a console handler and second a file handler
    # This is done to keep the console handler while other handler will be erased

    # Create console handler
    console = logging.StreamHandler()
    console.setLevel(logging.WARNING)
    formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logger.addHandler(console)

    # Create file handler
    file = logging.FileHandler(filename=os.path.join(config.get_execdir(), 'qtlab.log'),
                               mode='a+b')
    file.setLevel(logging.INFO)
    formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s: %(message)s (%(filename)s:%(lineno)d)',
                                  datefmt='%Y-%m-%d %H:%M')
    file.setFormatter(formatter)
    logger.addHandler(file)

    logging.info('Starting a Qtlab session')
Exemplo n.º 2
0
def _setup_logging():

    # Create logger
    logger = logging.getLogger()

    # Set the default level at info as the file level
    logger.setLevel(logging.INFO)

    # We add first a console handler and second a file handler
    # This is done to keep the console handler while other handler will be erased

    # Create console handler
    console = logging.StreamHandler()
    console.setLevel(logging.WARNING)
    formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logger.addHandler(console)

    # Create file handler
    file = logging.FileHandler(filename=os.path.join(config.get_execdir(),
                                                     'qtlab.log'),
                               mode='a+b')
    file.setLevel(logging.INFO)
    formatter = logging.Formatter(
        fmt=
        '%(asctime)s %(levelname)-8s: %(message)s (%(filename)s:%(lineno)d)',
        datefmt='%Y-%m-%d %H:%M')
    file.setFormatter(formatter)
    logger.addHandler(file)

    logging.info('Starting a Qtlab session')
Exemplo n.º 3
0
def _setup_logging():
    logging.basicConfig(level=logging.INFO,
        format='%(asctime)s %(levelname)-8s: %(message)s (%(filename)s:%(lineno)d)',
        datefmt='%Y-%m-%d %H:%M',
        filename=os.path.join(config.get_execdir(), 'qtlibs_%s.log' % datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S')),
        filemode='a+')
    console = logging.StreamHandler()
    console.setLevel(logging.WARNING)
    formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)
Exemplo n.º 4
0
def _setup_logging():
    logging.basicConfig(level=logging.INFO,
        format='%(asctime)s %(levelname)-8s: %(message)s (%(filename)s:%(lineno)d)',
        datefmt='%Y-%m-%d %H:%M',
        filename=os.path.join(config.get_execdir(), 'qtlab.log'),
        filemode='a+')
    console = logging.StreamHandler()
    console.setLevel(logging.WARNING)
    formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)
Exemplo n.º 5
0
from lib import config, lockfile
import os

_lockname = os.path.join(config.get_execdir(), 'qtlab.lock')
lockfile.set_filename(_lockname)
del _lockname

msg = "QTlab already running, start with '-f' to force start.\n"
msg += "Press s<enter> to start anyway or just <enter> to quit."
lockfile.check_lockfile(msg)