We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Fix logging issue
Currently, the logging is not working as intended. E.g. the formatting was ignored for WARNING and INFO log are not printed out.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `elasticdl/python/elasticdl/master/main.py`
Content:
```
1 import logging
2 import time
3 import argparse
4 import os
5 import recordio
6 
7 import grpc
8 import tensorflow as tf
9 
10 tf.enable_eager_execution()
11 
12 from contextlib import closing
13 from concurrent import futures
14 from elasticdl.proto import elasticdl_pb2_grpc
15 from elasticdl.python.elasticdl.master.servicer import MasterServicer
16 from elasticdl.python.elasticdl.master.task_queue import _TaskQueue
17 from elasticdl.python.elasticdl.master.k8s_worker_manager import WorkerManager
18 from elasticdl.python.elasticdl.common.model_helper import load_user_model, build_model
19 
20 
21 def _make_task_queue(data_dir, record_per_task, num_epoch):
22     f_records = {}
23     for f in os.listdir(data_dir):
24         p = os.path.join(data_dir, f)
25         with closing(recordio.Index(p)) as rio:
26             f_records[p] = rio.num_records()
27     return _TaskQueue(f_records, record_per_task, num_epoch)
28 
29 
30 def _parse_args():
31     parser = argparse.ArgumentParser(description="ElasticDL Master")
32     parser.add_argument(
33         "--model_file",
34         help="Full file path of user defined neural model",
35         required=True,
36     )
37     parser.add_argument(
38         "--train_data_dir",
39         help="Training data directory. Files should be in RecordIO format",
40         required=True,
41     )
42     parser.add_argument("--record_per_task", type=int, required=True)
43     parser.add_argument("--num_epoch", type=int, required=True)
44     parser.add_argument(
45         "--grads_to_wait",
46         type=int,
47         help="Number of gradients to wait before updating model",
48         required=True,
49     )
50     parser.add_argument(
51         "--minibatch_size",
52         type=int,
53         help="Minibatch size used by workers to compute gradients",
54         required=True,
55     )
56     parser.add_argument(
57         "--num_worker",
58         type=int,
59         help="the number of workers used in training",
60         default=0,
61     )
62     parser.add_argument(
63         "--worker_cpu_request",
64         help="the minimal cpu required by worker in training",
65         default="1000m",
66     )
67     parser.add_argument(
68         "--worker_cpu_limit",
69         help="the maximal cpu used by worker in training",
70         default="1000m",
71     )
72     parser.add_argument(
73         "--worker_memory_request",
74         help="the minimal memory required by worker in training",
75         default="4096Mi",
76     )
77     parser.add_argument(
78         "--worker_memory_limit",
79         help="the maximal memory used by worker in training",
80         default="4096Mi",
81     )
82     parser.add_argument(
83         "--worker_pod_priority",
84         help="the requested priority of worker pod")
85     parser.add_argument(
86         "--worker_image", help="docker image for worker", default=None
87     )
88     parser.add_argument("--job_name", help="job name", required=True)
89     parser.add_argument(
90         "--codec_type",
91         default="bytes",
92         choices=["tf_example", "bytes"],
93         help="Type of codec(tf_example or bytes)",
94     )
95     parser.add_argument("--volume_name",
96         help="the volume name of network filesytem")
97     parser.add_argument("--mount_path",
98         help="the mount path in the docker container")
99     parser.add_argument(
100         "--log_level",
101         choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
102         type=str.upper,
103         default='WARNING',
104         help="the logging level",
105     )
106     parser.add_argument("--image_pull_policy",
107         help="the image pull policy of master and worker")
108     return parser.parse_args()
109 
110 
111 def main():
112     args = _parse_args()
113 
114     # TODO: pass port via flags.
115     PORT = 50001
116 
117     # Initialize logger
118     logging.basicConfig(
119         format='%(asctime)s %(name)s %(levelname)-8s '
120         '[%(filename)s:%(lineno)d] %(message)s',
121     )
122     # Set level for ROOT logger.
123     logging.getLogger().setLevel(args.log_level)
124     logger = logging.getLogger(__name__)
125 
126     task_q = _make_task_queue(
127         args.train_data_dir, args.record_per_task, args.num_epoch
128     )
129     model_module = load_user_model(args.model_file)
130     model_inst = model_module.model
131     build_model(model_inst, model_module.feature_columns())
132     optimizer = model_module.optimizer()
133 
134     server = grpc.server(futures.ThreadPoolExecutor(max_workers=64))
135     elasticdl_pb2_grpc.add_MasterServicer_to_server(
136         MasterServicer(
137             args.grads_to_wait,
138             args.minibatch_size,
139             optimizer,
140             task_q,
141             init_var=model_inst.trainable_variables,
142         ),
143         server,
144     )
145     server.add_insecure_port("[::]:{}".format(PORT))
146     server.start()
147     logger.info("Server started at port: %d", PORT)
148 
149     if args.num_worker:
150         master_addr = "%s:%d" % (os.getenv("MY_POD_IP", "localhost"), PORT)
151         worker_command = ["python"]
152         worker_args = [
153             "-m",
154             "elasticdl.python.elasticdl.worker.main",
155             "--model_file",
156             args.model_file,
157             "--master_addr",
158             master_addr,
159             "--codec_type",
160             args.codec_type
161         ]
162 
163         worker_manager = WorkerManager(
164             task_q,
165             job_name=args.job_name,
166             worker_image=args.worker_image,
167             command=worker_command,
168             args=worker_args,
169             namespace="default",
170             num_worker=args.num_worker,
171             cpu_request=args.worker_cpu_request,
172             cpu_limit=args.worker_cpu_limit,
173             memory_request=args.worker_memory_request,
174             memory_limit=args.worker_memory_limit,
175             pod_priority=args.worker_pod_priority,
176             mount_path=args.mount_path,
177             volume_name=args.volume_name,
178             image_pull_policy=args.image_pull_policy,
179             restart_policy="Never",
180         )
181         worker_manager.start_workers()
182 
183     try:
184         while True:
185             if task_q.finished():
186                 break
187             time.sleep(30)
188     except KeyboardInterrupt:
189         logger.warning("Server stopping")
190 
191     server.stop(0)
192 
193 
194 if __name__ == "__main__":
195     main()
196
```
--- 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()

```

diff --git a/elasticdl/python/elasticdl/master/main.py b/elasticdl/python/elasticdl/master/main.py
--- a/elasticdl/python/elasticdl/master/main.py
+++ b/elasticdl/python/elasticdl/master/main.py
@@ -157,7 +157,9 @@
             "--master_addr",
             master_addr,
             "--codec_type",
-            args.codec_type
+            args.codec_type,
+            "--log_level",
+            args.log_level
         ]
 
         worker_manager = WorkerManager(

{"golden_diff": "diff --git a/elasticdl/python/elasticdl/master/main.py b/elasticdl/python/elasticdl/master/main.py\n--- a/elasticdl/python/elasticdl/master/main.py\n+++ b/elasticdl/python/elasticdl/master/main.py\n@@ -157,7 +157,9 @@\n             \"--master_addr\",\n             master_addr,\n             \"--codec_type\",\n-            args.codec_type\n+            args.codec_type,\n+            \"--log_level\",\n+            args.log_level\n         ]\n \n         worker_manager = WorkerManager(\n", "issue": "Fix logging issue\nCurrently, the logging is not working as intended. E.g. the formatting was ignored for WARNING and INFO log are not printed out.\n", "before_files": [{"content": "import logging\nimport time\nimport argparse\nimport os\nimport recordio\n\nimport grpc\nimport tensorflow as tf\n\ntf.enable_eager_execution()\n\nfrom contextlib import closing\nfrom concurrent import futures\nfrom elasticdl.proto import elasticdl_pb2_grpc\nfrom elasticdl.python.elasticdl.master.servicer import MasterServicer\nfrom elasticdl.python.elasticdl.master.task_queue import _TaskQueue\nfrom elasticdl.python.elasticdl.master.k8s_worker_manager import WorkerManager\nfrom elasticdl.python.elasticdl.common.model_helper import load_user_model, build_model\n\n\ndef _make_task_queue(data_dir, record_per_task, num_epoch):\n    f_records = {}\n    for f in os.listdir(data_dir):\n        p = os.path.join(data_dir, f)\n        with closing(recordio.Index(p)) as rio:\n            f_records[p] = rio.num_records()\n    return _TaskQueue(f_records, record_per_task, num_epoch)\n\n\ndef _parse_args():\n    parser = argparse.ArgumentParser(description=\"ElasticDL Master\")\n    parser.add_argument(\n        \"--model_file\",\n        help=\"Full file path of user defined neural model\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--train_data_dir\",\n        help=\"Training data directory. Files should be in RecordIO format\",\n        required=True,\n    )\n    parser.add_argument(\"--record_per_task\", type=int, required=True)\n    parser.add_argument(\"--num_epoch\", type=int, required=True)\n    parser.add_argument(\n        \"--grads_to_wait\",\n        type=int,\n        help=\"Number of gradients to wait before updating model\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--minibatch_size\",\n        type=int,\n        help=\"Minibatch size used by workers to compute gradients\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--num_worker\",\n        type=int,\n        help=\"the number of workers used in training\",\n        default=0,\n    )\n    parser.add_argument(\n        \"--worker_cpu_request\",\n        help=\"the minimal cpu required by worker in training\",\n        default=\"1000m\",\n    )\n    parser.add_argument(\n        \"--worker_cpu_limit\",\n        help=\"the maximal cpu used by worker in training\",\n        default=\"1000m\",\n    )\n    parser.add_argument(\n        \"--worker_memory_request\",\n        help=\"the minimal memory required by worker in training\",\n        default=\"4096Mi\",\n    )\n    parser.add_argument(\n        \"--worker_memory_limit\",\n        help=\"the maximal memory used by worker in training\",\n        default=\"4096Mi\",\n    )\n    parser.add_argument(\n        \"--worker_pod_priority\",\n        help=\"the requested priority of worker pod\")\n    parser.add_argument(\n        \"--worker_image\", help=\"docker image for worker\", default=None\n    )\n    parser.add_argument(\"--job_name\", help=\"job name\", required=True)\n    parser.add_argument(\n        \"--codec_type\",\n        default=\"bytes\",\n        choices=[\"tf_example\", \"bytes\"],\n        help=\"Type of codec(tf_example or bytes)\",\n    )\n    parser.add_argument(\"--volume_name\",\n        help=\"the volume name of network filesytem\")\n    parser.add_argument(\"--mount_path\",\n        help=\"the mount path in the docker container\")\n    parser.add_argument(\n        \"--log_level\",\n        choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],\n        type=str.upper,\n        default='WARNING',\n        help=\"the logging level\",\n    )\n    parser.add_argument(\"--image_pull_policy\",\n        help=\"the image pull policy of master and worker\")\n    return parser.parse_args()\n\n\ndef main():\n    args = _parse_args()\n\n    # TODO: pass port via flags.\n    PORT = 50001\n\n    # Initialize logger\n    logging.basicConfig(\n        format='%(asctime)s %(name)s %(levelname)-8s '\n        '[%(filename)s:%(lineno)d] %(message)s',\n    )\n    # Set level for ROOT logger.\n    logging.getLogger().setLevel(args.log_level)\n    logger = logging.getLogger(__name__)\n\n    task_q = _make_task_queue(\n        args.train_data_dir, args.record_per_task, args.num_epoch\n    )\n    model_module = load_user_model(args.model_file)\n    model_inst = model_module.model\n    build_model(model_inst, model_module.feature_columns())\n    optimizer = model_module.optimizer()\n\n    server = grpc.server(futures.ThreadPoolExecutor(max_workers=64))\n    elasticdl_pb2_grpc.add_MasterServicer_to_server(\n        MasterServicer(\n            args.grads_to_wait,\n            args.minibatch_size,\n            optimizer,\n            task_q,\n            init_var=model_inst.trainable_variables,\n        ),\n        server,\n    )\n    server.add_insecure_port(\"[::]:{}\".format(PORT))\n    server.start()\n    logger.info(\"Server started at port: %d\", PORT)\n\n    if args.num_worker:\n        master_addr = \"%s:%d\" % (os.getenv(\"MY_POD_IP\", \"localhost\"), PORT)\n        worker_command = [\"python\"]\n        worker_args = [\n            \"-m\",\n            \"elasticdl.python.elasticdl.worker.main\",\n            \"--model_file\",\n            args.model_file,\n            \"--master_addr\",\n            master_addr,\n            \"--codec_type\",\n            args.codec_type\n        ]\n\n        worker_manager = WorkerManager(\n            task_q,\n            job_name=args.job_name,\n            worker_image=args.worker_image,\n            command=worker_command,\n            args=worker_args,\n            namespace=\"default\",\n            num_worker=args.num_worker,\n            cpu_request=args.worker_cpu_request,\n            cpu_limit=args.worker_cpu_limit,\n            memory_request=args.worker_memory_request,\n            memory_limit=args.worker_memory_limit,\n            pod_priority=args.worker_pod_priority,\n            mount_path=args.mount_path,\n            volume_name=args.volume_name,\n            image_pull_policy=args.image_pull_policy,\n            restart_policy=\"Never\",\n        )\n        worker_manager.start_workers()\n\n    try:\n        while True:\n            if task_q.finished():\n                break\n            time.sleep(30)\n    except KeyboardInterrupt:\n        logger.warning(\"Server stopping\")\n\n    server.stop(0)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "elasticdl/python/elasticdl/master/main.py"}], "after_files": [{"content": "import logging\nimport time\nimport argparse\nimport os\nimport recordio\n\nimport grpc\nimport tensorflow as tf\n\ntf.enable_eager_execution()\n\nfrom contextlib import closing\nfrom concurrent import futures\nfrom elasticdl.proto import elasticdl_pb2_grpc\nfrom elasticdl.python.elasticdl.master.servicer import MasterServicer\nfrom elasticdl.python.elasticdl.master.task_queue import _TaskQueue\nfrom elasticdl.python.elasticdl.master.k8s_worker_manager import WorkerManager\nfrom elasticdl.python.elasticdl.common.model_helper import load_user_model, build_model\n\n\ndef _make_task_queue(data_dir, record_per_task, num_epoch):\n    f_records = {}\n    for f in os.listdir(data_dir):\n        p = os.path.join(data_dir, f)\n        with closing(recordio.Index(p)) as rio:\n            f_records[p] = rio.num_records()\n    return _TaskQueue(f_records, record_per_task, num_epoch)\n\n\ndef _parse_args():\n    parser = argparse.ArgumentParser(description=\"ElasticDL Master\")\n    parser.add_argument(\n        \"--model_file\",\n        help=\"Full file path of user defined neural model\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--train_data_dir\",\n        help=\"Training data directory. Files should be in RecordIO format\",\n        required=True,\n    )\n    parser.add_argument(\"--record_per_task\", type=int, required=True)\n    parser.add_argument(\"--num_epoch\", type=int, required=True)\n    parser.add_argument(\n        \"--grads_to_wait\",\n        type=int,\n        help=\"Number of gradients to wait before updating model\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--minibatch_size\",\n        type=int,\n        help=\"Minibatch size used by workers to compute gradients\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--num_worker\",\n        type=int,\n        help=\"the number of workers used in training\",\n        default=0,\n    )\n    parser.add_argument(\n        \"--worker_cpu_request\",\n        help=\"the minimal cpu required by worker in training\",\n        default=\"1000m\",\n    )\n    parser.add_argument(\n        \"--worker_cpu_limit\",\n        help=\"the maximal cpu used by worker in training\",\n        default=\"1000m\",\n    )\n    parser.add_argument(\n        \"--worker_memory_request\",\n        help=\"the minimal memory required by worker in training\",\n        default=\"4096Mi\",\n    )\n    parser.add_argument(\n        \"--worker_memory_limit\",\n        help=\"the maximal memory used by worker in training\",\n        default=\"4096Mi\",\n    )\n    parser.add_argument(\n        \"--worker_pod_priority\",\n        help=\"the requested priority of worker pod\")\n    parser.add_argument(\n        \"--worker_image\", help=\"docker image for worker\", default=None\n    )\n    parser.add_argument(\"--job_name\", help=\"job name\", required=True)\n    parser.add_argument(\n        \"--codec_type\",\n        default=\"bytes\",\n        choices=[\"tf_example\", \"bytes\"],\n        help=\"Type of codec(tf_example or bytes)\",\n    )\n    parser.add_argument(\"--volume_name\",\n        help=\"the volume name of network filesytem\")\n    parser.add_argument(\"--mount_path\",\n        help=\"the mount path in the docker container\")\n    parser.add_argument(\n        \"--log_level\",\n        choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],\n        type=str.upper,\n        default='WARNING',\n        help=\"the logging level\",\n    )\n    parser.add_argument(\"--image_pull_policy\",\n        help=\"the image pull policy of master and worker\")\n    return parser.parse_args()\n\n\ndef main():\n    args = _parse_args()\n\n    # TODO: pass port via flags.\n    PORT = 50001\n\n    # Initialize logger\n    logging.basicConfig(\n        format='%(asctime)s %(name)s %(levelname)-8s '\n        '[%(filename)s:%(lineno)d] %(message)s',\n    )\n    # Set level for ROOT logger.\n    logging.getLogger().setLevel(args.log_level)\n    logger = logging.getLogger(__name__)\n\n    task_q = _make_task_queue(\n        args.train_data_dir, args.record_per_task, args.num_epoch\n    )\n    model_module = load_user_model(args.model_file)\n    model_inst = model_module.model\n    build_model(model_inst, model_module.feature_columns())\n    optimizer = model_module.optimizer()\n\n    server = grpc.server(futures.ThreadPoolExecutor(max_workers=64))\n    elasticdl_pb2_grpc.add_MasterServicer_to_server(\n        MasterServicer(\n            args.grads_to_wait,\n            args.minibatch_size,\n            optimizer,\n            task_q,\n            init_var=model_inst.trainable_variables,\n        ),\n        server,\n    )\n    server.add_insecure_port(\"[::]:{}\".format(PORT))\n    server.start()\n    logger.info(\"Server started at port: %d\", PORT)\n\n    if args.num_worker:\n        master_addr = \"%s:%d\" % (os.getenv(\"MY_POD_IP\", \"localhost\"), PORT)\n        worker_command = [\"python\"]\n        worker_args = [\n            \"-m\",\n            \"elasticdl.python.elasticdl.worker.main\",\n            \"--model_file\",\n            args.model_file,\n            \"--master_addr\",\n            master_addr,\n            \"--codec_type\",\n            args.codec_type,\n            \"--log_level\",\n            args.log_level\n        ]\n\n        worker_manager = WorkerManager(\n            task_q,\n            job_name=args.job_name,\n            worker_image=args.worker_image,\n            command=worker_command,\n            args=worker_args,\n            namespace=\"default\",\n            num_worker=args.num_worker,\n            cpu_request=args.worker_cpu_request,\n            cpu_limit=args.worker_cpu_limit,\n            memory_request=args.worker_memory_request,\n            memory_limit=args.worker_memory_limit,\n            pod_priority=args.worker_pod_priority,\n            mount_path=args.mount_path,\n            volume_name=args.volume_name,\n            image_pull_policy=args.image_pull_policy,\n            restart_policy=\"Never\",\n        )\n        worker_manager.start_workers()\n\n    try:\n        while True:\n            if task_q.finished():\n                break\n            time.sleep(30)\n    except KeyboardInterrupt:\n        logger.warning(\"Server stopping\")\n\n    server.stop(0)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "elasticdl/python/elasticdl/master/main.py"}]}