#!/usr/bin/env python
from __future__ import print_function
import logging
import os


def setup_logging():
    # Set log level of the messages to show.
    logger = logging.getLogger()
    level_name = os.environ.get('BUCK_WRAPPER_LOG_LEVEL', 'INFO')
    level_name_to_level = {
        'CRITICAL': logging.CRITICAL,
        'ERROR': logging.ERROR,
        'WARNING': logging.WARNING,
        'INFO': logging.INFO,
        'DEBUG': logging.DEBUG,
        'NOTSET': logging.NOTSET,
    }
    level = level_name_to_level.get(level_name.upper(), logging.INFO)
    logger.setLevel(level)
    # Set formatter for log messages.
    console_handler = logging.StreamHandler()
    formatter = logging.Formatter('%(message)s')
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)

#!/usr/bin/env python
from __future__ import print_function
import logging
import os


def setup_logging():
    # Set log level of the messages to show.

    level_name = os.environ.get('BUCK_WRAPPER_LOG_LEVEL', 'INFO')
    level_name_to_level = {
        'CRITICAL': logging.CRITICAL,
        'ERROR': logging.ERROR,
        'WARNING': logging.WARNING,
        'INFO': logging.INFO,
        'DEBUG': logging.DEBUG,
        'NOTSET': logging.NOTSET,
    }
    level = level_name_to_level.get(level_name.upper(), logging.INFO)
    logging.basicConfig(
        level=level,
        format=(
            '%(asctime)s [%(levelname)s][%(filename)s:%(lineno)d] %(message)s'
        ))

Make buck wrapper logs human-readable.
Make buck wrapper logs human-readable.

Summary: Simplify logging setup and make its format human-readable

Test Plan:
$ BUCK_WRAPPER_LOG_LEVEL=DEBUG buck run buck -- --version
  buck version 64999e5d3b446c062da5c3cc282a2e78ce133c92
  2017-12-05 14:08:08,073 [DEBUG][buck.py:80] [Errno 2] No such file or directory

perviously it would produce:

  buck version 64999e5d3b446c062da5c3cc282a2e78ce133c92
  [Errno 2] No such file or directory

which does not leave much to investigate

Reviewed By: sbalabanov

fbshipit-source-id: 2d0b977
