How to use coloredlogs - 10 common examples

To help you get started, we’ve selected a few coloredlogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcugent / vsc-base / test / fancylogger.py View on Github external
def test_colorize_auto_tty(self):
        # with colorize=Colorize.AUTO on a stream connected to a TTY,
        # return colorizing formatter
        stream = _get_tty_stream()
        cls = fancylogger._screenLogFormatterFactory(fancylogger.Colorize.AUTO, stream)
        self.assertEqual(cls, coloredlogs.ColoredFormatter)
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_increase_verbosity(self):
        """Make sure increase_verbosity() respects default and custom levels."""
        # Start from a known state.
        set_level(logging.INFO)
        assert get_level() == logging.INFO
        # INFO -> VERBOSE.
        increase_verbosity()
        assert get_level() == logging.VERBOSE
        # VERBOSE -> DEBUG.
        increase_verbosity()
        assert get_level() == logging.DEBUG
        # DEBUG -> SPAM.
        increase_verbosity()
        assert get_level() == logging.SPAM
        # SPAM -> NOTSET.
        increase_verbosity()
        assert get_level() == logging.NOTSET
        # NOTSET -> NOTSET.
        increase_verbosity()
        assert get_level() == logging.NOTSET
github paylogic / py2deb / py2deb / tests.py View on Github external
1. Sets up verbose logging to the terminal. When a test fails the logging
       output can help to perform a post-mortem analysis of the failure in
       question (even when its hard to reproduce locally). This is especially
       useful when debugging remote test failures, whether they happened on
       Travis CI or a user's local system.

    2. Creates temporary directories where the pip download cache and the
       pip-accel binary cache are located. Isolating the pip-accel binary cache
       from the user's system is meant to ensure that the tests are as
       independent from the user's system as possible. The function
       :func:`tearDownModule` is responsible for cleaning up the temporary
       directory after the test suite finishes.
    """
    # Initialize verbose logging to the terminal.
    coloredlogs.install()
    coloredlogs.increase_verbosity()
    # Create temporary directories to store the pip download cache and
    # pip-accel's binary cache, to make sure these tests run isolated from the
    # rest of the system.
    os.environ['PIP_DOWNLOAD_CACHE'] = create_temporary_directory()
    os.environ['PIP_ACCEL_CACHE'] = create_temporary_directory()
github xolox / python-redock / redock / tests.py View on Github external
def setUp(self):
        coloredlogs.install()
        coloredlogs.set_level(logging.DEBUG)
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_increase_verbosity(self):
        """Make sure increase_verbosity() respects default and custom levels."""
        # Start from a known state.
        set_level(logging.INFO)
        assert get_level() == logging.INFO
        # INFO -> VERBOSE.
        increase_verbosity()
        assert get_level() == logging.VERBOSE
        # VERBOSE -> DEBUG.
        increase_verbosity()
        assert get_level() == logging.DEBUG
        # DEBUG -> SPAM.
        increase_verbosity()
        assert get_level() == logging.SPAM
        # SPAM -> NOTSET.
        increase_verbosity()
        assert get_level() == logging.NOTSET
        # NOTSET -> NOTSET.
        increase_verbosity()
        assert get_level() == logging.NOTSET
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_decrease_verbosity(self):
        """Make sure decrease_verbosity() respects default and custom levels."""
        # Start from a known state.
        set_level(logging.INFO)
        assert get_level() == logging.INFO
        # INFO -> NOTICE.
        decrease_verbosity()
        assert get_level() == logging.NOTICE
        # NOTICE -> WARNING.
        decrease_verbosity()
        assert get_level() == logging.WARNING
        # WARNING -> SUCCESS.
        decrease_verbosity()
        assert get_level() == logging.SUCCESS
        # SUCCESS -> ERROR.
        decrease_verbosity()
        assert get_level() == logging.ERROR
        # ERROR -> CRITICAL.
        decrease_verbosity()
        assert get_level() == logging.CRITICAL
github paylogic / pip-accel / pip_accel / tests.py View on Github external
def setUp(self):
        """Reset logging verbosity before each test."""
        coloredlogs.set_level(logging.INFO)
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_is_verbose(self):
        """Make sure is_verbose() does what it should :-)."""
        set_level(logging.INFO)
        assert not is_verbose()
        set_level(logging.DEBUG)
        assert is_verbose()
        set_level(logging.VERBOSE)
        assert is_verbose()
github ph4r05 / monero-agent / trezor_monero_test / test_trezor.py View on Github external
import time
import logging
import coloredlogs
from monero_glue.messages.DebugMoneroDiagRequest import DebugMoneroDiagRequest

from trezorlib import debuglink, device

from monero_glue.agent import agent_lite
from monero_glue.xmr import crypto, monero, wallet
from monero_glue.xmr import bulletproof as bp
from monero_glue.xmr import bulletproof_cl as bpcl
from monero_glue_test.base_agent_test import BaseAgentTest
from monero_glue.trezor import manager as tmanager

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)


class TrezorTest(BaseAgentTest):
    def __init__(self, *args, **kwargs):
        super(TrezorTest, self).__init__(*args, **kwargs)
        self.trezor_proxy = None  # type: tmanager.Trezor
        self.agent = None  # type: agent_lite.Agent
        self.creds = None
        self.test_only_tsx = False
        self.is_debug = True
        self.do_timing = int(os.getenv('TREZOR_TEST_TIMING', '1'))
        self.do_bp_off = int(os.getenv('TREZOR_TEST_BP_OFF', '0'))
        self.time_start = None
        self.timing_bins = {}
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_find_hostname(self):
        """Make sure :func:`~find_hostname()` works correctly."""
        assert find_hostname()
        # Create a temporary file as a placeholder for e.g. /etc/debian_chroot.
        fd, temporary_file = tempfile.mkstemp()
        try:
            with open(temporary_file, 'w') as handle:
                handle.write('first line\n')
                handle.write('second line\n')
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure the chroot file is being read.
            assert find_hostname() == 'first line'
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)
            os.unlink(temporary_file)
        # Test that unreadable chroot files don't break coloredlogs.
        try:
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure that a usable value is still produced.
            assert find_hostname()
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)