Exemplo n.º 1
0
Arquivo: test.py Projeto: grnet/kamaki
 def test_get_log_filename(self):
     from kamaki.cli.logger import get_log_filename, LOG_FILE
     f = NamedTemporaryFile()
     for e in LOG_FILE:
         LOG_FILE.pop()
     LOG_FILE.append(f.name)
     self.assertEqual(get_log_filename(), f.name)
     LOG_FILE.pop()
     LOG_FILE.append(2 * f.name)
     print('\n  Should print error msg here: ')
     self.assertEqual(get_log_filename(), None)
Exemplo n.º 2
0
 def test_get_log_filename(self):
     from kamaki.cli.logger import get_log_filename, LOG_FILE
     f = NamedTemporaryFile()
     for e in LOG_FILE:
         LOG_FILE.pop()
     LOG_FILE.append(f.name)
     self.assertEqual(get_log_filename(), f.name)
     LOG_FILE.pop()
     LOG_FILE.append(2 * f.name)
     print('\n  Should print error msg here: ')
     self.assertEqual(get_log_filename(), None)
Exemplo n.º 3
0
def _setup_logging(debug=False, verbose=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', logging.INFO, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.INFO, rfmt)
        logger.add_stream_logger(__name__, logging.INFO)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    global kloger
    kloger = logger.get_logger(__name__)
Exemplo n.º 4
0
def _setup_logging(debug=False, verbose=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', logging.INFO, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.INFO, rfmt)
        logger.add_stream_logger(__name__, logging.INFO)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    global kloger
    kloger = logger.get_logger(__name__)
Exemplo n.º 5
0
def _setup_logging(debug=False, verbose=False, _verbose_with_data=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', DEBUGV, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', DEBUGV, rfmt)
        logger.add_stream_logger(__name__, DEBUGV)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    if _verbose_with_data:
        from kamaki import clients
        clients.Client.LOG_DATA = True
    global kloger
    kloger = logger.get_logger(__name__)
Exemplo n.º 6
0
def _setup_logging(debug=False, verbose=False, _verbose_with_data=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', DEBUGV, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', DEBUGV, rfmt)
        logger.add_stream_logger(__name__, DEBUGV)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    if _verbose_with_data:
        from kamaki import clients
        clients.Client.LOG_DATA = True
    global kloger
    kloger = logger.get_logger(__name__)