prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Verbose mode not working in v3.0.0 RC2
  ##### Steps to reproduce the problem:
  
  1. Start mitmdump with -v or --verbose flag
  2. No DEBUG level logs prints on standard output
  
  ##### Any other comments? What have you tried so far?
  
  In old stable version (2.0.2) the same steps produce desired output.
  
  ##### System information
  
  Mitmproxy: 3.0.0.dev1136 (commit 15f525e)
  Python:    3.6.3
  OpenSSL:   OpenSSL 1.1.0g  2 Nov 2017
  Platform:  Linux-3.16.0-5-amd64-x86_64-with-debian-8.9
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mitmproxy/tools/main.py`
  Content:
  ```
  1 from __future__ import print_function  # this is here for the version check to work on Python 2.
  2 
  3 import sys
  4 
  5 if sys.version_info < (3, 5):
  6     # This must be before any mitmproxy imports, as they already break!
  7     # Keep all other imports below with the 'noqa' magic comment.
  8     print("#" * 49, file=sys.stderr)
  9     print("# mitmproxy only supports Python 3.5 and above! #", file=sys.stderr)
  10     print("#" * 49, file=sys.stderr)
  11 
  12 import argparse  # noqa
  13 import os  # noqa
  14 import signal  # noqa
  15 import typing  # noqa
  16 
  17 from mitmproxy.tools import cmdline  # noqa
  18 from mitmproxy import exceptions, master  # noqa
  19 from mitmproxy import options  # noqa
  20 from mitmproxy import optmanager  # noqa
  21 from mitmproxy import proxy  # noqa
  22 from mitmproxy import log  # noqa
  23 from mitmproxy.utils import debug, arg_check  # noqa
  24 
  25 
  26 def assert_utf8_env():
  27     spec = ""
  28     for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
  29         spec += os.environ.get(i, "").lower()
  30     if "utf" not in spec:
  31         print(
  32             "Error: mitmproxy requires a UTF console environment.",
  33             file=sys.stderr
  34         )
  35         print(
  36             "Set your LANG environment variable to something like en_US.UTF-8",
  37             file=sys.stderr
  38         )
  39         sys.exit(1)
  40 
  41 
  42 def process_options(parser, opts, args):
  43     if args.version:
  44         print(debug.dump_system_info())
  45         sys.exit(0)
  46     if args.quiet or args.options or args.commands:
  47         args.verbosity = 'error'
  48         args.flow_detail = 0
  49 
  50     adict = {}
  51     for n in dir(args):
  52         if n in opts:
  53             adict[n] = getattr(args, n)
  54     opts.merge(adict)
  55 
  56     return proxy.config.ProxyConfig(opts)
  57 
  58 
  59 def run(
  60         master_cls: typing.Type[master.Master],
  61         make_parser: typing.Callable[[options.Options], argparse.ArgumentParser],
  62         arguments: typing.Sequence[str],
  63         extra: typing.Callable[[typing.Any], dict] = None
  64 ):  # pragma: no cover
  65     """
  66         extra: Extra argument processing callable which returns a dict of
  67         options.
  68     """
  69     debug.register_info_dumpers()
  70 
  71     opts = options.Options()
  72     master = master_cls(opts)
  73 
  74     parser = make_parser(opts)
  75 
  76     # To make migration from 2.x to 3.0 bearable.
  77     if "-R" in sys.argv and sys.argv[sys.argv.index("-R") + 1].startswith("http"):
  78         print("-R is used for specifying replacements.\n"
  79               "To use mitmproxy in reverse mode please use --mode reverse:SPEC instead")
  80 
  81     try:
  82         args = parser.parse_args(arguments)
  83     except SystemExit:
  84         arg_check.check()
  85         sys.exit(1)
  86     try:
  87         unknown = optmanager.load_paths(opts, args.conf)
  88         pconf = process_options(parser, opts, args)
  89         server = None  # type: typing.Any
  90         if pconf.options.server:
  91             try:
  92                 server = proxy.server.ProxyServer(pconf)
  93             except exceptions.ServerException as v:
  94                 print(str(v), file=sys.stderr)
  95                 sys.exit(1)
  96         else:
  97             server = proxy.server.DummyServer(pconf)
  98 
  99         master.server = server
  100         master.addons.trigger("configure", opts.keys())
  101         master.addons.trigger("tick")
  102         remaining = opts.update_known(**unknown)
  103         if remaining and log.log_tier(opts.verbosity) > 1:
  104             print("Ignored options: %s" % remaining)
  105         if args.options:
  106             print(optmanager.dump_defaults(opts))
  107             sys.exit(0)
  108         if args.commands:
  109             master.commands.dump()
  110             sys.exit(0)
  111         opts.set(*args.setoptions)
  112         if extra:
  113             opts.update(**extra(args))
  114 
  115         def cleankill(*args, **kwargs):
  116             master.shutdown()
  117 
  118         signal.signal(signal.SIGTERM, cleankill)
  119         master.run()
  120     except exceptions.OptionsError as e:
  121         print("%s: %s" % (sys.argv[0], e), file=sys.stderr)
  122         sys.exit(1)
  123     except (KeyboardInterrupt, RuntimeError) as e:
  124         pass
  125     return master
  126 
  127 
  128 def mitmproxy(args=None):  # pragma: no cover
  129     if os.name == "nt":
  130         print("Error: mitmproxy's console interface is not supported on Windows. "
  131               "You can run mitmdump or mitmweb instead.", file=sys.stderr)
  132         sys.exit(1)
  133 
  134     assert_utf8_env()
  135 
  136     from mitmproxy.tools import console
  137     run(console.master.ConsoleMaster, cmdline.mitmproxy, args)
  138 
  139 
  140 def mitmdump(args=None):  # pragma: no cover
  141     from mitmproxy.tools import dump
  142 
  143     def extra(args):
  144         if args.filter_args:
  145             v = " ".join(args.filter_args)
  146             return dict(
  147                 view_filter=v,
  148                 save_stream_filter=v,
  149             )
  150         return {}
  151 
  152     m = run(dump.DumpMaster, cmdline.mitmdump, args, extra)
  153     if m and m.errorcheck.has_errored:
  154         sys.exit(1)
  155 
  156 
  157 def mitmweb(args=None):  # pragma: no cover
  158     from mitmproxy.tools import web
  159     run(web.master.WebMaster, cmdline.mitmweb, args)
  160
  ```
  --- 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/mitmproxy/tools/main.py b/mitmproxy/tools/main.py
  --- a/mitmproxy/tools/main.py
  +++ b/mitmproxy/tools/main.py
  @@ -44,8 +44,13 @@
           print(debug.dump_system_info())
           sys.exit(0)
       if args.quiet or args.options or args.commands:
  +        # also reduce log verbosity if --options or --commands is passed,
  +        # we don't want log messages from regular startup then.
           args.verbosity = 'error'
           args.flow_detail = 0
  +    if args.verbose:
  +        args.verbosity = 'debug'
  +        args.flow_detail = 2
   
       adict = {}
       for n in dir(args):
  
verification_info: {"golden_diff": "diff --git a/mitmproxy/tools/main.py b/mitmproxy/tools/main.py\n--- a/mitmproxy/tools/main.py\n+++ b/mitmproxy/tools/main.py\n@@ -44,8 +44,13 @@\n         print(debug.dump_system_info())\n         sys.exit(0)\n     if args.quiet or args.options or args.commands:\n+        # also reduce log verbosity if --options or --commands is passed,\n+        # we don't want log messages from regular startup then.\n         args.verbosity = 'error'\n         args.flow_detail = 0\n+    if args.verbose:\n+        args.verbosity = 'debug'\n+        args.flow_detail = 2\n \n     adict = {}\n     for n in dir(args):\n", "issue": "Verbose mode not working in v3.0.0 RC2\n##### Steps to reproduce the problem:\r\n\r\n1. Start mitmdump with -v or --verbose flag\r\n2. No DEBUG level logs prints on standard output\r\n\r\n##### Any other comments? What have you tried so far?\r\n\r\nIn old stable version (2.0.2) the same steps produce desired output.\r\n\r\n##### System information\r\n\r\nMitmproxy: 3.0.0.dev1136 (commit 15f525e)\r\nPython:    3.6.3\r\nOpenSSL:   OpenSSL 1.1.0g  2 Nov 2017\r\nPlatform:  Linux-3.16.0-5-amd64-x86_64-with-debian-8.9\n", "before_files": [{"content": "from __future__ import print_function  # this is here for the version check to work on Python 2.\n\nimport sys\n\nif sys.version_info < (3, 5):\n    # This must be before any mitmproxy imports, as they already break!\n    # Keep all other imports below with the 'noqa' magic comment.\n    print(\"#\" * 49, file=sys.stderr)\n    print(\"# mitmproxy only supports Python 3.5 and above! #\", file=sys.stderr)\n    print(\"#\" * 49, file=sys.stderr)\n\nimport argparse  # noqa\nimport os  # noqa\nimport signal  # noqa\nimport typing  # noqa\n\nfrom mitmproxy.tools import cmdline  # noqa\nfrom mitmproxy import exceptions, master  # noqa\nfrom mitmproxy import options  # noqa\nfrom mitmproxy import optmanager  # noqa\nfrom mitmproxy import proxy  # noqa\nfrom mitmproxy import log  # noqa\nfrom mitmproxy.utils import debug, arg_check  # noqa\n\n\ndef assert_utf8_env():\n    spec = \"\"\n    for i in [\"LANG\", \"LC_CTYPE\", \"LC_ALL\"]:\n        spec += os.environ.get(i, \"\").lower()\n    if \"utf\" not in spec:\n        print(\n            \"Error: mitmproxy requires a UTF console environment.\",\n            file=sys.stderr\n        )\n        print(\n            \"Set your LANG environment variable to something like en_US.UTF-8\",\n            file=sys.stderr\n        )\n        sys.exit(1)\n\n\ndef process_options(parser, opts, args):\n    if args.version:\n        print(debug.dump_system_info())\n        sys.exit(0)\n    if args.quiet or args.options or args.commands:\n        args.verbosity = 'error'\n        args.flow_detail = 0\n\n    adict = {}\n    for n in dir(args):\n        if n in opts:\n            adict[n] = getattr(args, n)\n    opts.merge(adict)\n\n    return proxy.config.ProxyConfig(opts)\n\n\ndef run(\n        master_cls: typing.Type[master.Master],\n        make_parser: typing.Callable[[options.Options], argparse.ArgumentParser],\n        arguments: typing.Sequence[str],\n        extra: typing.Callable[[typing.Any], dict] = None\n):  # pragma: no cover\n    \"\"\"\n        extra: Extra argument processing callable which returns a dict of\n        options.\n    \"\"\"\n    debug.register_info_dumpers()\n\n    opts = options.Options()\n    master = master_cls(opts)\n\n    parser = make_parser(opts)\n\n    # To make migration from 2.x to 3.0 bearable.\n    if \"-R\" in sys.argv and sys.argv[sys.argv.index(\"-R\") + 1].startswith(\"http\"):\n        print(\"-R is used for specifying replacements.\\n\"\n              \"To use mitmproxy in reverse mode please use --mode reverse:SPEC instead\")\n\n    try:\n        args = parser.parse_args(arguments)\n    except SystemExit:\n        arg_check.check()\n        sys.exit(1)\n    try:\n        unknown = optmanager.load_paths(opts, args.conf)\n        pconf = process_options(parser, opts, args)\n        server = None  # type: typing.Any\n        if pconf.options.server:\n            try:\n                server = proxy.server.ProxyServer(pconf)\n            except exceptions.ServerException as v:\n                print(str(v), file=sys.stderr)\n                sys.exit(1)\n        else:\n            server = proxy.server.DummyServer(pconf)\n\n        master.server = server\n        master.addons.trigger(\"configure\", opts.keys())\n        master.addons.trigger(\"tick\")\n        remaining = opts.update_known(**unknown)\n        if remaining and log.log_tier(opts.verbosity) > 1:\n            print(\"Ignored options: %s\" % remaining)\n        if args.options:\n            print(optmanager.dump_defaults(opts))\n            sys.exit(0)\n        if args.commands:\n            master.commands.dump()\n            sys.exit(0)\n        opts.set(*args.setoptions)\n        if extra:\n            opts.update(**extra(args))\n\n        def cleankill(*args, **kwargs):\n            master.shutdown()\n\n        signal.signal(signal.SIGTERM, cleankill)\n        master.run()\n    except exceptions.OptionsError as e:\n        print(\"%s: %s\" % (sys.argv[0], e), file=sys.stderr)\n        sys.exit(1)\n    except (KeyboardInterrupt, RuntimeError) as e:\n        pass\n    return master\n\n\ndef mitmproxy(args=None):  # pragma: no cover\n    if os.name == \"nt\":\n        print(\"Error: mitmproxy's console interface is not supported on Windows. \"\n              \"You can run mitmdump or mitmweb instead.\", file=sys.stderr)\n        sys.exit(1)\n\n    assert_utf8_env()\n\n    from mitmproxy.tools import console\n    run(console.master.ConsoleMaster, cmdline.mitmproxy, args)\n\n\ndef mitmdump(args=None):  # pragma: no cover\n    from mitmproxy.tools import dump\n\n    def extra(args):\n        if args.filter_args:\n            v = \" \".join(args.filter_args)\n            return dict(\n                view_filter=v,\n                save_stream_filter=v,\n            )\n        return {}\n\n    m = run(dump.DumpMaster, cmdline.mitmdump, args, extra)\n    if m and m.errorcheck.has_errored:\n        sys.exit(1)\n\n\ndef mitmweb(args=None):  # pragma: no cover\n    from mitmproxy.tools import web\n    run(web.master.WebMaster, cmdline.mitmweb, args)\n", "path": "mitmproxy/tools/main.py"}], "after_files": [{"content": "from __future__ import print_function  # this is here for the version check to work on Python 2.\n\nimport sys\n\nif sys.version_info < (3, 5):\n    # This must be before any mitmproxy imports, as they already break!\n    # Keep all other imports below with the 'noqa' magic comment.\n    print(\"#\" * 49, file=sys.stderr)\n    print(\"# mitmproxy only supports Python 3.5 and above! #\", file=sys.stderr)\n    print(\"#\" * 49, file=sys.stderr)\n\nimport argparse  # noqa\nimport os  # noqa\nimport signal  # noqa\nimport typing  # noqa\n\nfrom mitmproxy.tools import cmdline  # noqa\nfrom mitmproxy import exceptions, master  # noqa\nfrom mitmproxy import options  # noqa\nfrom mitmproxy import optmanager  # noqa\nfrom mitmproxy import proxy  # noqa\nfrom mitmproxy import log  # noqa\nfrom mitmproxy.utils import debug, arg_check  # noqa\n\n\ndef assert_utf8_env():\n    spec = \"\"\n    for i in [\"LANG\", \"LC_CTYPE\", \"LC_ALL\"]:\n        spec += os.environ.get(i, \"\").lower()\n    if \"utf\" not in spec:\n        print(\n            \"Error: mitmproxy requires a UTF console environment.\",\n            file=sys.stderr\n        )\n        print(\n            \"Set your LANG environment variable to something like en_US.UTF-8\",\n            file=sys.stderr\n        )\n        sys.exit(1)\n\n\ndef process_options(parser, opts, args):\n    if args.version:\n        print(debug.dump_system_info())\n        sys.exit(0)\n    if args.quiet or args.options or args.commands:\n        # also reduce log verbosity if --options or --commands is passed,\n        # we don't want log messages from regular startup then.\n        args.verbosity = 'error'\n        args.flow_detail = 0\n    if args.verbose:\n        args.verbosity = 'debug'\n        args.flow_detail = 2\n\n    adict = {}\n    for n in dir(args):\n        if n in opts:\n            adict[n] = getattr(args, n)\n    opts.merge(adict)\n\n    return proxy.config.ProxyConfig(opts)\n\n\ndef run(\n        master_cls: typing.Type[master.Master],\n        make_parser: typing.Callable[[options.Options], argparse.ArgumentParser],\n        arguments: typing.Sequence[str],\n        extra: typing.Callable[[typing.Any], dict] = None\n):  # pragma: no cover\n    \"\"\"\n        extra: Extra argument processing callable which returns a dict of\n        options.\n    \"\"\"\n    debug.register_info_dumpers()\n\n    opts = options.Options()\n    master = master_cls(opts)\n\n    parser = make_parser(opts)\n\n    # To make migration from 2.x to 3.0 bearable.\n    if \"-R\" in sys.argv and sys.argv[sys.argv.index(\"-R\") + 1].startswith(\"http\"):\n        print(\"-R is used for specifying replacements.\\n\"\n              \"To use mitmproxy in reverse mode please use --mode reverse:SPEC instead\")\n\n    try:\n        args = parser.parse_args(arguments)\n    except SystemExit:\n        arg_check.check()\n        sys.exit(1)\n    try:\n        unknown = optmanager.load_paths(opts, args.conf)\n        pconf = process_options(parser, opts, args)\n        server = None  # type: typing.Any\n        if pconf.options.server:\n            try:\n                server = proxy.server.ProxyServer(pconf)\n            except exceptions.ServerException as v:\n                print(str(v), file=sys.stderr)\n                sys.exit(1)\n        else:\n            server = proxy.server.DummyServer(pconf)\n\n        master.server = server\n        master.addons.trigger(\"configure\", opts.keys())\n        master.addons.trigger(\"tick\")\n        remaining = opts.update_known(**unknown)\n        if remaining and log.log_tier(opts.verbosity) > 1:\n            print(\"Ignored options: %s\" % remaining)\n        if args.options:\n            print(optmanager.dump_defaults(opts))\n            sys.exit(0)\n        if args.commands:\n            master.commands.dump()\n            sys.exit(0)\n        opts.set(*args.setoptions)\n        if extra:\n            opts.update(**extra(args))\n\n        def cleankill(*args, **kwargs):\n            master.shutdown()\n\n        signal.signal(signal.SIGTERM, cleankill)\n        master.run()\n    except exceptions.OptionsError as e:\n        print(\"%s: %s\" % (sys.argv[0], e), file=sys.stderr)\n        sys.exit(1)\n    except (KeyboardInterrupt, RuntimeError) as e:\n        pass\n    return master\n\n\ndef mitmproxy(args=None):  # pragma: no cover\n    if os.name == \"nt\":\n        print(\"Error: mitmproxy's console interface is not supported on Windows. \"\n              \"You can run mitmdump or mitmweb instead.\", file=sys.stderr)\n        sys.exit(1)\n\n    assert_utf8_env()\n\n    from mitmproxy.tools import console\n    run(console.master.ConsoleMaster, cmdline.mitmproxy, args)\n\n\ndef mitmdump(args=None):  # pragma: no cover\n    from mitmproxy.tools import dump\n\n    def extra(args):\n        if args.filter_args:\n            v = \" \".join(args.filter_args)\n            return dict(\n                view_filter=v,\n                save_stream_filter=v,\n            )\n        return {}\n\n    m = run(dump.DumpMaster, cmdline.mitmdump, args, extra)\n    if m and m.errorcheck.has_errored:\n        sys.exit(1)\n\n\ndef mitmweb(args=None):  # pragma: no cover\n    from mitmproxy.tools import web\n    run(web.master.WebMaster, cmdline.mitmweb, args)\n", "path": "mitmproxy/tools/main.py"}]}