コード例 #1
0
def pytest_sessionstart(session):
    BASE_FORMAT = "[%(name)s][%(levelname)-6s] %(message)s"
    FILE_FORMAT = "[%(asctime)s]" + BASE_FORMAT

    root_logger = logging.getLogger('conftest')
    dir_path = os.path.dirname(os.path.realpath(__file__))
    top_level = _dir(_dir(dir_path))
    log_file = os.path.join(top_level, 'pytest-functional-tests.log')

    root_logger.setLevel(logging.DEBUG)

    # File Logger
    fh = logging.FileHandler(log_file)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(logging.Formatter(FILE_FORMAT, "%Y-%m-%d %H:%M:%S"))

    root_logger.addHandler(fh)
コード例 #2
0
ファイル: conftest.py プロジェクト: valancej/anchore-cli
def pytest_sessionstart(session):
    BASE_FORMAT = "[%(name)s][%(levelname)-6s] %(message)s"
    FILE_FORMAT = "[%(asctime)s]" + BASE_FORMAT

    root_logger = logging.getLogger('conftest')
    dir_path = os.path.dirname(os.path.realpath(__file__))
    top_level = _dir(_dir(dir_path))
    log_file = os.path.join(top_level, 'pytest-functional-tests.log')

    root_logger.setLevel(logging.DEBUG)

    # File Logger
    fh = logging.FileHandler(log_file)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(logging.Formatter(FILE_FORMAT, "%Y-%m-%d %H:%M:%S"))

    root_logger.addHandler(fh)

    # Setup the environment variable for the container
    image = os.environ.get('PYTEST_CONTAINER', 'anchore/inline-scan:latest')
    os.environ['PYTEST_CONTAINER'] = image
コード例 #3
0
#  This software is distributed under the 3-clause BSD License.
#  ___________________________________________________________________________
#
# Utility classes for working with the logger
#

import logging
from pyutilib.misc import LogHandler

# __file__ fails if script is called in different ways on Windows
# __file__ fails if someone does os.chdir() before
# sys.argv[0] also fails because it doesn't not always contains the path
from os.path import dirname as _dir, abspath as _abs
import inspect

_pyomo_base = _dir(_dir(_dir(_abs(inspect.getfile(inspect.currentframe())))))

#
# Set up the root Pyomo namespace logger
#
_logger = logging.getLogger('pyomo')
_logger.addHandler(
    LogHandler(_pyomo_base,
               verbosity=lambda: _logger.isEnabledFor(logging.DEBUG)))
_logger.setLevel(logging.WARNING)


class LoggingIntercept(object):
    """Context manager for intercepting messages sent to a log stream

    This class is designed to enable easy testing of log messages.
コード例 #4
0
        for indent, par in paragraphs:
            if not indent:
                indent = ''
            # Bulleted lists get indented with a hanging indent
            if par and len(par[0]) > 1 and par[0][0] in '-*':
                hang = ' '*4
            else:
                hang = ''
            self.stream.write( '%s\n' % (
                textwrap.fill(
                    ' '.join(par),
                    width=self.wrap,
                    initial_indent=self.subsequent_indent+indent,
                    subsequent_indent=self.subsequent_indent+indent+hang ), ))


#
# Set up default logging for PyUtilib
#
# __file__ fails if script is called in different ways on Windows
# __file__ fails if someone does os.chdir() before
# sys.argv[0] also fails because it does not always contain the path
from os.path import dirname as _dir, abspath as _abs
import inspect
_pyutilib_base = _dir(_dir(_dir(_abs(inspect.getfile(inspect.currentframe())))))

_logger = logging.getLogger('pyutilib')
_logger.setLevel(logging.WARNING)
_logger.addHandler( LogHandler(
    _pyutilib_base, verbosity=lambda: _logger.isEnabledFor(logging.DEBUG)))