How to use the coloredlogs.DEFAULT_FIELD_STYLES function in coloredlogs

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 mozilla / iris_firefox / iris / __main__.py View on Github external
from api.core.util.parse_args import get_global_args, parse_args
from api.core.util.test_loader import load_tests, scan_all_tests
from api.core.util.version_parser import get_latest_scraper_details, get_version_from_path, get_scraper_details
from api.helpers.general import launch_firefox, quit_firefox, get_firefox_channel, get_firefox_version, \
    get_firefox_build_id
from firefox import cleanup
from local_web_server import LocalWebServer
from test_runner import run

restore_terminal_encoding = None
LOG_FILENAME = 'iris_log.log'
LOG_FORMAT = '%(asctime)s [%(levelname)s] [%(name)s] %(message)s'
logger = logging.getLogger(__name__)

coloredlogs.DEFAULT_LOG_FORMAT = LOG_FORMAT
coloredlogs.DEFAULT_FIELD_STYLES = {'levelname': {'color': 'cyan', 'bold': True},
                                    'name': {'color': 'cyan', 'bold': True}}
coloredlogs.DEFAULT_LEVEL_STYLES = {'warning': {'color': 'yellow', 'bold': True},
                                    'success': {'color': 'green', 'bold': True},
                                    'error': {'color': 'red', 'bold': True}}


def main():
    """This is the main entry point defined in setup.py"""
    Iris()


class Iris(object):
    process_list = None

    def __init__(self):
        cleanup.init()
github picoCTF / picoCTF / picoCTF-shell / shell_manager / run.py View on Github external
default=False,
        help="interpret the given value as JSON",
    )
    config_set_parser.add_argument(
        "--allow-type-change",
        action="store_true",
        default=False,
        help="allow the supplied field to change types if already specified",
    )
    config_set_parser.set_defaults(func=set_configuration_option)

    args = parser.parse_args()

    if args.colorize == "never":
        coloredlogs.DEFAULT_LEVEL_STYLES = {}
        coloredlogs.DEFAULT_FIELD_STYLES = {}

    coloredlogs.install()

    if args.debug:
        coloredlogs.set_level(logging.DEBUG)
    try:
        if "func" in args:
            args.func(args)
        else:
            parser.print_help()
    except FatalException:
        exit(1)
github mozilla / iris / moziris / util / logger_manager.py View on Github external
def set_log_format():

    if core_args.level < 20:
        log_format = "%(asctime)s [%(levelname)s] %(message)s"
        coloredlogs.DEFAULT_LOG_FORMAT = log_format
        coloredlogs.DEFAULT_FIELD_STYLES = {
            "levelname": {"color": "cyan", "bold": True}
        }
        coloredlogs.DEFAULT_LEVEL_STYLES = {
            "warning": {"color": "yellow", "bold": True},
            "success": {"color": "green", "bold": True},
            "error": {"color": "red", "bold": True},
        }
    else:
        log_format = "%(message)s"
        coloredlogs.DEFAULT_LOG_FORMAT = log_format
        coloredlogs.DEFAULT_LEVEL_STYLES = {
            "warning": {"color": "yellow", "bold": True},
            "success": {"color": "green", "bold": True},
            "error": {"color": "red", "bold": True},
        }
    return log_format
github alexa-pi / AlexaPi / src / main.py View on Github external
import subprocess
import hashlib

import yaml
import requests
import coloredlogs

import alexapi.config
import alexapi.tunein as tunein
import alexapi.capture
import alexapi.triggers as triggers
from alexapi.exceptions import ConfigurationException
from alexapi.constants import RequestType, PlayerActivity

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s')
coloredlogs.DEFAULT_FIELD_STYLES = {
	'hostname': {'color': 'magenta'},
	'programname': {'color': 'cyan'},
	'name': {'color': 'blue'},
	'levelname': {'color': 'magenta', 'bold': True},
	'asctime': {'color': 'green'}
}
coloredlogs.DEFAULT_LEVEL_STYLES = {
	'info': {'color': 'blue'},
	'critical': {'color': 'red', 'bold': True},
	'error': {'color': 'red'},
	'debug': {'color': 'green'},
	'warning': {'color': 'yellow'}
}

# Get arguments
parser = optparse.OptionParser()