How to use the colorlog.basicConfig function in colorlog

To help you get started, we’ve selected a few colorlog 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 decalage2 / ViperMonkey / vipermonkey / vbashell.py View on Github external
help='VBA expression to be evaluated')
    parser.add_option('-l', '--loglevel', dest="loglevel", action="store", default=DEFAULT_LOG_LEVEL,
                            help="logging level debug/info/warning/error/critical (default=%default)")

    (options, args) = parser.parse_args()

    # Print help if no arguments are passed
    # if len(args) == 0:
    #     print(__doc__)
    #     parser.print_help()
    #     sys.exit()

    # setup logging to the console
    # logging.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(levelname)-8s %(message)s')

    colorlog.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(log_color)s%(levelname)-8s %(message)s')

    if options.parse_file:
        parse(options.parse_file)

    if options.eval_expr:
        eval_expression(options.eval_expr)

    while True:
        try:
            print("VBA> ", end='')
            cmd = raw_input()

            if cmd.startswith('exit'):
                break

            if cmd.startswith('parse'):
github decalage2 / ViperMonkey / vipermonkey / vmonkey.py View on Github external
(options, args) = parser.parse_args()

    # Print version information and exit?
    if (options.print_version):
        print_version()
        sys.exit(0)
    
    # Print help if no arguments are passed
    if len(args) == 0:
        safe_print(__doc__)
        parser.print_help()
        sys.exit(0)

    # setup logging to the console
    # logging.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(levelname)-8s %(message)s')
    colorlog.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(log_color)s%(levelname)-8s %(message)s')

    json_results = []

    for container, filename, data in xglob.iter_files(args,
                                                      recursive=options.recursive,
                                                      zip_password=options.zip_password,
                                                      zip_fname=options.zip_fname):

        # ignore directory names stored in zip files:
        if container and filename.endswith('/'):
            continue
        if options.scan_expressions:
            process_file_scanexpr(container, filename, data)
        else:
            entry_points = None
            if (options.entry_points is not None):
github decalage2 / ViperMonkey / vipermonkey / vmonkey.py View on Github external
safe_print('FILE: ' + str(display_filename))
        # FIXME: the code below only works if the file is on disk and not in a zip archive
        # TODO: merge process_file and _process_file
        try:
            input_file = open(filename,'rb')
            data = input_file.read()
            input_file.close()
        except IOError as e:
            log.error("Cannot open file '" + str(filename) + "'. " + str(e))
            return None
    r = _process_file(filename, data, altparser=altparser, strip_useless=strip_useless,
                      entry_points=entry_points, time_limit=time_limit, display_int_iocs=display_int_iocs,
                      artifact_dir=artifact_dir, out_file_name=out_file_name)

    # Reset logging.
    colorlog.basicConfig(level=logging.ERROR, format='%(log_color)s%(levelname)-8s %(message)s')

    # Done.
    return r
github fivestars-os / aladdin / commands / python / main.py View on Github external
parser.add_argument("-i", "--init", action="store_true", help="Force initialization logic")
    parser.add_argument(
        "--dev", action="store_true", help="Mount host's aladdin directory onto aladdin container"
    )
    parser.add_argument("--image", help="Use the specified aladdin image (if building it yourself)")
    parser.add_argument(
        "--skip-prompts",
        action="store_true",
        help="Skip confirmation prompts during command execution",
    )
    parser.add_argument(
        "--non-terminal", action="store_true", help="Run aladdin container without tty"
    )

    # Initialize logging across python
    colorlog.basicConfig(format="%(log_color)s%(levelname)s:%(message)s", level=logging.INFO)
    logging.getLogger("botocore").setLevel(logging.WARNING)

    args = parser.parse_args()
    args.func(args)
github zizi1532 / BasisCustomize / src / main.py View on Github external
# Dataloader
from model_src.CustomDataset.yelp2013 import yelp2013
from model_src.CustomDataset.polmed import polmed
from model_src.CustomDataset.aapr import aapr

# Pytorch.Ignite Packages
from ignite.engine import Events, Engine
from ignite.contrib.handlers import ProgressBar

# model
from model_src.model import Classifier


logging.disable(logging.DEBUG)
colorlog.basicConfig(
	filename=None,
	level=logging.NOTSET,
	format="%(log_color)s[%(levelname)s:%(asctime)s]%(reset)s %(message)s",
	datefmt="%Y-%m-%d %H:%M:%S"
)
parser = argparse.ArgumentParser()
baseline_models = ['BiLSTM']
cust_models = ['word_cust', 'encoder_cust', 'attention_cust', 'linear_cust', 'bias_cust']
basis_cust_models = ['word_basis_cust', 'encoder_basis_cust', 'attention_basis_cust', 'linear_basis_cust', 'bias_basis_cust']
model_choices = baseline_models + cust_models + basis_cust_models
parser.add_argument("--random_seed", type=int, default=33)
parser.add_argument("--model_type", choices=model_choices, help="Give model type.")
parser.add_argument("--domain", type=str, choices=['yelp2013', 'polmed', 'aapr'], default="yelp2013")
parser.add_argument("--num_bases", type=int, default=0)
parser.add_argument("--vocab_dir", type=str)
parser.add_argument("--train_datadir", type=str, default="./processed_data/flat_data.p")
github decalage2 / ViperMonkey / vipermonkey / vmonkey.py View on Github external
strip_useless=False,
                 entry_points=None,
                 time_limit=None,
                 verbose=False,
                 display_int_iocs=False,
                 set_log=False,
                 tee_log=False,
                 tee_bytes=0,
                 artifact_dir=None,
                 out_file_name=None):

    # set logging level
    if verbose:
        colorlog.basicConfig(level=logging.DEBUG, format='%(log_color)s%(levelname)-8s %(message)s')
    elif set_log:
        colorlog.basicConfig(level=logging.INFO, format='%(log_color)s%(levelname)-8s %(message)s')

    # assume they want a tee'd file if they give bytes for it
    if tee_bytes > 0:
        tee_log = True

    # add handler for tee'd log file
    if tee_log:

        tee_filename = "./" + filename
        if ("/" in filename):
            tee_filename = "./" + filename[filename.rindex("/") + 1:]

        if tee_bytes > 0:
            capped_handler = CappedFileHandler(tee_filename + ".log", sizecap=tee_bytes)
            capped_handler.setFormatter(logging.Formatter("%(levelname)-8s %(message)s"))
            log.addHandler(capped_handler)
github notadamking / RLTrader / lib / util / logger.py View on Github external
def init_logger(dunder_name, show_debug=False) -> logging.Logger:
    log_format = (
        '%(asctime)s - '
        '%(name)s - '
        '%(funcName)s - '
        '%(levelname)s - '
        '%(message)s'
    )
    bold_seq = '\033[1m'
    colorlog_format = (
        f'{bold_seq} '
        '%(log_color)s '
        f'{log_format}'
    )
    colorlog.basicConfig(format=colorlog_format)
    logging.getLogger('tensorflow').disabled = True
    logger = logging.getLogger(dunder_name)

    if show_debug:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    # Note: these file outputs are left in place as examples
    # Feel free to uncomment and use the outputs as you like

    # Output full log
    # fh = logging.FileHandler(os.path.join('data', log', 'trading.log')
    # fh.setLevel(logging.DEBUG)
    # formatter = logging.Formatter(log_format)
    # fh.setFormatter(formatter)