prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Running DVC outside of Git dir
  We should handle all the cases like this.
  
  ```
  cd /
  $ dvc repro
  No handlers could be found for logger "dvc"
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dvc/logger.py`
  Content:
  ```
  1 import sys
  2 import logging
  3 
  4 import colorama
  5 
  6 
  7 colorama.init()
  8 
  9 
  10 class Logger(object):
  11     FMT = '%(message)s'
  12     DEFAULT_LEVEL = logging.INFO
  13 
  14     LEVEL_MAP = {
  15         'debug': logging.DEBUG,
  16         'info': logging.INFO,
  17         'warn': logging.WARNING,
  18         'error': logging.ERROR
  19     }
  20 
  21     COLOR_MAP = {
  22         'debug': colorama.Fore.BLUE,
  23         'warn': colorama.Fore.YELLOW,
  24         'error': colorama.Fore.RED
  25     }
  26 
  27     def __init__(self, config=None):
  28         sh = logging.StreamHandler(sys.stdout)
  29         sh.setFormatter(logging.Formatter(self.FMT))
  30         sh.setLevel(logging.DEBUG)
  31 
  32         self.logger().addHandler(sh)
  33         level = None
  34         if config:
  35             level = config['Global'].get('LogLevel', None)
  36         self.set_level(level)
  37 
  38     @staticmethod
  39     def logger():
  40         return logging.getLogger('dvc')
  41 
  42     @staticmethod
  43     def set_level(level=None):
  44         if not level:
  45             lvl = Logger.DEFAULT_LEVEL
  46         else:
  47             lvl = Logger.LEVEL_MAP.get(level.lower(), Logger.DEFAULT_LEVEL)
  48         Logger.logger().setLevel(lvl)
  49 
  50     @staticmethod
  51     def be_quiet():
  52         Logger.logger().setLevel(logging.CRITICAL)
  53 
  54     @staticmethod
  55     def be_verbose():
  56         Logger.logger().setLevel(logging.DEBUG)
  57 
  58     @staticmethod
  59     def colorize(msg, typ):
  60         header = ''
  61         footer = ''
  62 
  63         if sys.stdout.isatty():
  64             header = Logger.COLOR_MAP.get(typ.lower(), '')
  65             footer = colorama.Style.RESET_ALL
  66 
  67         return u'{}{}{}'.format(header, msg, footer)
  68 
  69     @staticmethod
  70     def error(msg, **kwargs):
  71         exc_info = Logger.logger().getEffectiveLevel() == logging.DEBUG
  72         return Logger.logger().error(Logger.colorize(msg, 'error'), exc_info=exc_info, **kwargs)
  73 
  74     @staticmethod
  75     def warn(msg, **kwargs):
  76         return Logger.logger().warn(Logger.colorize(msg, 'warn'), **kwargs)
  77 
  78     @staticmethod
  79     def debug(msg, **kwargs):
  80         return Logger.logger().debug(Logger.colorize(msg, 'debug'), **kwargs)
  81 
  82     @staticmethod
  83     def info(msg, **kwargs):
  84         return Logger.logger().info(Logger.colorize(msg, 'info'), **kwargs)
  85
  ```
  
  Path: `dvc/main.py`
  Content:
  ```
  1 from dvc.logger import Logger
  2 from dvc.cli import parse_args
  3 
  4 def main(argv=None):
  5     args = parse_args(argv)
  6 
  7     try:
  8         cmd = args.func(args)
  9     except Exception as ex:
  10         Logger.error('Initialization error: {}'.format(str(ex)))
  11         return 255
  12 
  13     return cmd.run_cmd()
  14
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/dvc/logger.py b/dvc/logger.py
  --- a/dvc/logger.py
  +++ b/dvc/logger.py
  @@ -25,15 +25,19 @@
       }
   
       def __init__(self, config=None):
  +        self.init(config)
  +
  +    @staticmethod
  +    def init(config=None):
           sh = logging.StreamHandler(sys.stdout)
  -        sh.setFormatter(logging.Formatter(self.FMT))
  +        sh.setFormatter(logging.Formatter(Logger.FMT))
           sh.setLevel(logging.DEBUG)
   
  -        self.logger().addHandler(sh)
  +        Logger.logger().addHandler(sh)
           level = None
           if config:
               level = config['Global'].get('LogLevel', None)
  -        self.set_level(level)
  +        Logger.set_level(level)
   
       @staticmethod
       def logger():
  diff --git a/dvc/main.py b/dvc/main.py
  --- a/dvc/main.py
  +++ b/dvc/main.py
  @@ -2,6 +2,8 @@
   from dvc.cli import parse_args
   
   def main(argv=None):
  +    Logger.init()
  +
       args = parse_args(argv)
   
       try:
  
verification_info: {"golden_diff": "diff --git a/dvc/logger.py b/dvc/logger.py\n--- a/dvc/logger.py\n+++ b/dvc/logger.py\n@@ -25,15 +25,19 @@\n     }\n \n     def __init__(self, config=None):\n+        self.init(config)\n+\n+    @staticmethod\n+    def init(config=None):\n         sh = logging.StreamHandler(sys.stdout)\n-        sh.setFormatter(logging.Formatter(self.FMT))\n+        sh.setFormatter(logging.Formatter(Logger.FMT))\n         sh.setLevel(logging.DEBUG)\n \n-        self.logger().addHandler(sh)\n+        Logger.logger().addHandler(sh)\n         level = None\n         if config:\n             level = config['Global'].get('LogLevel', None)\n-        self.set_level(level)\n+        Logger.set_level(level)\n \n     @staticmethod\n     def logger():\ndiff --git a/dvc/main.py b/dvc/main.py\n--- a/dvc/main.py\n+++ b/dvc/main.py\n@@ -2,6 +2,8 @@\n from dvc.cli import parse_args\n \n def main(argv=None):\n+    Logger.init()\n+\n     args = parse_args(argv)\n \n     try:\n", "issue": "Running DVC outside of Git dir\nWe should handle all the cases like this.\r\n\r\n```\r\ncd /\r\n$ dvc repro\r\nNo handlers could be found for logger \"dvc\"\r\n```\n", "before_files": [{"content": "import sys\nimport logging\n\nimport colorama\n\n\ncolorama.init()\n\n\nclass Logger(object):\n    FMT = '%(message)s'\n    DEFAULT_LEVEL = logging.INFO\n\n    LEVEL_MAP = {\n        'debug': logging.DEBUG,\n        'info': logging.INFO,\n        'warn': logging.WARNING,\n        'error': logging.ERROR\n    }\n\n    COLOR_MAP = {\n        'debug': colorama.Fore.BLUE,\n        'warn': colorama.Fore.YELLOW,\n        'error': colorama.Fore.RED\n    }\n\n    def __init__(self, config=None):\n        sh = logging.StreamHandler(sys.stdout)\n        sh.setFormatter(logging.Formatter(self.FMT))\n        sh.setLevel(logging.DEBUG)\n\n        self.logger().addHandler(sh)\n        level = None\n        if config:\n            level = config['Global'].get('LogLevel', None)\n        self.set_level(level)\n\n    @staticmethod\n    def logger():\n        return logging.getLogger('dvc')\n\n    @staticmethod\n    def set_level(level=None):\n        if not level:\n            lvl = Logger.DEFAULT_LEVEL\n        else:\n            lvl = Logger.LEVEL_MAP.get(level.lower(), Logger.DEFAULT_LEVEL)\n        Logger.logger().setLevel(lvl)\n\n    @staticmethod\n    def be_quiet():\n        Logger.logger().setLevel(logging.CRITICAL)\n\n    @staticmethod\n    def be_verbose():\n        Logger.logger().setLevel(logging.DEBUG)\n\n    @staticmethod\n    def colorize(msg, typ):\n        header = ''\n        footer = ''\n\n        if sys.stdout.isatty():\n            header = Logger.COLOR_MAP.get(typ.lower(), '')\n            footer = colorama.Style.RESET_ALL\n\n        return u'{}{}{}'.format(header, msg, footer)\n\n    @staticmethod\n    def error(msg, **kwargs):\n        exc_info = Logger.logger().getEffectiveLevel() == logging.DEBUG\n        return Logger.logger().error(Logger.colorize(msg, 'error'), exc_info=exc_info, **kwargs)\n\n    @staticmethod\n    def warn(msg, **kwargs):\n        return Logger.logger().warn(Logger.colorize(msg, 'warn'), **kwargs)\n\n    @staticmethod\n    def debug(msg, **kwargs):\n        return Logger.logger().debug(Logger.colorize(msg, 'debug'), **kwargs)\n\n    @staticmethod\n    def info(msg, **kwargs):\n        return Logger.logger().info(Logger.colorize(msg, 'info'), **kwargs)\n", "path": "dvc/logger.py"}, {"content": "from dvc.logger import Logger\nfrom dvc.cli import parse_args\n\ndef main(argv=None):\n    args = parse_args(argv)\n\n    try:\n        cmd = args.func(args)\n    except Exception as ex:\n        Logger.error('Initialization error: {}'.format(str(ex)))\n        return 255\n\n    return cmd.run_cmd()\n", "path": "dvc/main.py"}], "after_files": [{"content": "import sys\nimport logging\n\nimport colorama\n\n\ncolorama.init()\n\n\nclass Logger(object):\n    FMT = '%(message)s'\n    DEFAULT_LEVEL = logging.INFO\n\n    LEVEL_MAP = {\n        'debug': logging.DEBUG,\n        'info': logging.INFO,\n        'warn': logging.WARNING,\n        'error': logging.ERROR\n    }\n\n    COLOR_MAP = {\n        'debug': colorama.Fore.BLUE,\n        'warn': colorama.Fore.YELLOW,\n        'error': colorama.Fore.RED\n    }\n\n    def __init__(self, config=None):\n        self.init(config)\n\n    @staticmethod\n    def init(config=None):\n        sh = logging.StreamHandler(sys.stdout)\n        sh.setFormatter(logging.Formatter(Logger.FMT))\n        sh.setLevel(logging.DEBUG)\n\n        Logger.logger().addHandler(sh)\n        level = None\n        if config:\n            level = config['Global'].get('LogLevel', None)\n        Logger.set_level(level)\n\n    @staticmethod\n    def logger():\n        return logging.getLogger('dvc')\n\n    @staticmethod\n    def set_level(level=None):\n        if not level:\n            lvl = Logger.DEFAULT_LEVEL\n        else:\n            lvl = Logger.LEVEL_MAP.get(level.lower(), Logger.DEFAULT_LEVEL)\n        Logger.logger().setLevel(lvl)\n\n    @staticmethod\n    def be_quiet():\n        Logger.logger().setLevel(logging.CRITICAL)\n\n    @staticmethod\n    def be_verbose():\n        Logger.logger().setLevel(logging.DEBUG)\n\n    @staticmethod\n    def colorize(msg, typ):\n        header = ''\n        footer = ''\n\n        if sys.stdout.isatty():\n            header = Logger.COLOR_MAP.get(typ.lower(), '')\n            footer = colorama.Style.RESET_ALL\n\n        return u'{}{}{}'.format(header, msg, footer)\n\n    @staticmethod\n    def error(msg, **kwargs):\n        exc_info = Logger.logger().getEffectiveLevel() == logging.DEBUG\n        return Logger.logger().error(Logger.colorize(msg, 'error'), exc_info=exc_info, **kwargs)\n\n    @staticmethod\n    def warn(msg, **kwargs):\n        return Logger.logger().warn(Logger.colorize(msg, 'warn'), **kwargs)\n\n    @staticmethod\n    def debug(msg, **kwargs):\n        return Logger.logger().debug(Logger.colorize(msg, 'debug'), **kwargs)\n\n    @staticmethod\n    def info(msg, **kwargs):\n        return Logger.logger().info(Logger.colorize(msg, 'info'), **kwargs)\n", "path": "dvc/logger.py"}, {"content": "from dvc.logger import Logger\nfrom dvc.cli import parse_args\n\ndef main(argv=None):\n    Logger.init()\n\n    args = parse_args(argv)\n\n    try:\n        cmd = args.func(args)\n    except Exception as ex:\n        Logger.error('Initialization error: {}'.format(str(ex)))\n        return 255\n\n    return cmd.run_cmd()\n", "path": "dvc/main.py"}]}