We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
syslog_json callback doesn't cast SYSLOG_PORT value from environment as integer
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
syslog_json callback plugin

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.1.0
```

##### CONFIGURATION
Specifying SYSLOG_PORT environment variable to target a non-default port:
SYSLOG_PORT=1514

##### OS / ENVIRONMENT
Redhat 6 (but this should affect any UNIX platform)

##### SUMMARY
The syslog_json callback plugin allows configuration of its target port by specifying the SYSLOG_PORT environment variable; however, it doesn't cast the value it obtains from get_env as int, so specifying a port number this way results in errors  on each task and no syslog output:

Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/handlers.py", line 806, in emit
    self.socket.sendto(msg, self.address)
TypeError: an integer is required

##### STEPS TO REPRODUCE
For any playbook, specify the syslog_json callback plugin and the syslog port environment variable:

<!--- Paste example playbooks or commands between quotes below -->
```yaml
ANSIBLE_STDOUT_CALLBACK=syslog_json SYSLOG_PORT=1514 ansible-playbook playbook.yml
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
No output to stdout, JSON output directed to syslog for each task.

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/handlers.py", line 806, in emit
    self.socket.sendto(msg, self.address)
TypeError: an integer is required
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/ansible/plugins/callback/syslog_json.py`
Content:
```
1 # Make coding more python3-ish
2 from __future__ import (absolute_import, division, print_function)
3 __metaclass__ = type
4 
5 import os
6 import json
7 
8 import logging
9 import logging.handlers
10 
11 import socket
12 
13 from ansible.plugins.callback import CallbackBase
14 
15 class CallbackModule(CallbackBase):
16     """
17     logs ansible-playbook and ansible runs to a syslog server in json format
18     make sure you have in ansible.cfg:
19         callback_plugins   = <path_to_callback_plugins_folder>
20     and put the plugin in <path_to_callback_plugins_folder>
21 
22     This plugin makes use of the following environment variables:
23         SYSLOG_SERVER   (optional): defaults to localhost
24         SYSLOG_PORT     (optional): defaults to 514
25         SYSLOG_FACILITY (optional): defaults to user
26     """
27     CALLBACK_VERSION = 2.0
28     CALLBACK_TYPE = 'aggregate'
29     CALLBACK_NAME = 'syslog_json'
30     CALLBACK_NEEDS_WHITELIST = True
31 
32     def __init__(self):
33 
34         super(CallbackModule, self).__init__()
35 
36         self.logger =  logging.getLogger('ansible logger')
37         self.logger.setLevel(logging.DEBUG)
38 
39         self.handler = logging.handlers.SysLogHandler(
40             address = (os.getenv('SYSLOG_SERVER','localhost'),
41                        os.getenv('SYSLOG_PORT',514)),
42             facility= os.getenv('SYSLOG_FACILITY',logging.handlers.SysLogHandler.LOG_USER)
43         )
44         self.logger.addHandler(self.handler)
45         self.hostname = socket.gethostname()
46 
47 
48     def runner_on_failed(self, host, res, ignore_errors=False):
49         self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))
50 
51     def runner_on_ok(self, host, res):
52         self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))
53 
54     def runner_on_skipped(self, host, item=None):
55         self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s' % (self.hostname,host, 'skipped'))
56 
57     def runner_on_unreachable(self, host, res):
58         self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))
59 
60     def runner_on_async_failed(self, host, res, jid):
61         self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))
62 
63     def playbook_on_import_for_host(self, host, imported_file):
64         self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: imported file %s' % (self.hostname,host,imported_file))
65 
66     def playbook_on_not_import_for_host(self, host, missing_file):
67         self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: missing file %s' % (self.hostname,host,missing_file))
68
```
--- 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/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py
--- a/lib/ansible/plugins/callback/syslog_json.py
+++ b/lib/ansible/plugins/callback/syslog_json.py
@@ -38,7 +38,7 @@
 
         self.handler = logging.handlers.SysLogHandler(
             address = (os.getenv('SYSLOG_SERVER','localhost'),
-                       os.getenv('SYSLOG_PORT',514)),
+                       int(os.getenv('SYSLOG_PORT',514))),
             facility= os.getenv('SYSLOG_FACILITY',logging.handlers.SysLogHandler.LOG_USER)
         )
         self.logger.addHandler(self.handler)

{"golden_diff": "diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py\n--- a/lib/ansible/plugins/callback/syslog_json.py\n+++ b/lib/ansible/plugins/callback/syslog_json.py\n@@ -38,7 +38,7 @@\n \n         self.handler = logging.handlers.SysLogHandler(\n             address = (os.getenv('SYSLOG_SERVER','localhost'),\n-                       os.getenv('SYSLOG_PORT',514)),\n+                       int(os.getenv('SYSLOG_PORT',514))),\n             facility= os.getenv('SYSLOG_FACILITY',logging.handlers.SysLogHandler.LOG_USER)\n         )\n         self.logger.addHandler(self.handler)\n", "issue": "syslog_json callback doesn't cast SYSLOG_PORT value from environment as integer\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the module/plugin/task/feature -->\r\nsyslog_json callback plugin\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \u201cansible --version\u201d between quotes below -->\r\n```\r\nansible 2.2.1.0\r\n```\r\n\r\n##### CONFIGURATION\r\nSpecifying SYSLOG_PORT environment variable to target a non-default port:\r\nSYSLOG_PORT=1514\r\n\r\n##### OS / ENVIRONMENT\r\nRedhat 6 (but this should affect any UNIX platform)\r\n\r\n##### SUMMARY\r\nThe syslog_json callback plugin allows configuration of its target port by specifying the SYSLOG_PORT environment variable; however, it doesn't cast the value it obtains from get_env as int, so specifying a port number this way results in errors  on each task and no syslog output:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python2.6/logging/handlers.py\", line 806, in emit\r\n    self.socket.sendto(msg, self.address)\r\nTypeError: an integer is required\r\n\r\n##### STEPS TO REPRODUCE\r\nFor any playbook, specify the syslog_json callback plugin and the syslog port environment variable:\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\nANSIBLE_STDOUT_CALLBACK=syslog_json SYSLOG_PORT=1514 ansible-playbook playbook.yml\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\nNo output to stdout, JSON output directed to syslog for each task.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python2.6/logging/handlers.py\", line 806, in emit\r\n    self.socket.sendto(msg, self.address)\r\nTypeError: an integer is required\r\n```\r\n\n", "before_files": [{"content": "# Make coding more python3-ish\nfrom __future__ import (absolute_import, division, print_function)\n__metaclass__ = type\n\nimport os\nimport json\n\nimport logging\nimport logging.handlers\n\nimport socket\n\nfrom ansible.plugins.callback import CallbackBase\n\nclass CallbackModule(CallbackBase):\n    \"\"\"\n    logs ansible-playbook and ansible runs to a syslog server in json format\n    make sure you have in ansible.cfg:\n        callback_plugins   = <path_to_callback_plugins_folder>\n    and put the plugin in <path_to_callback_plugins_folder>\n\n    This plugin makes use of the following environment variables:\n        SYSLOG_SERVER   (optional): defaults to localhost\n        SYSLOG_PORT     (optional): defaults to 514\n        SYSLOG_FACILITY (optional): defaults to user\n    \"\"\"\n    CALLBACK_VERSION = 2.0\n    CALLBACK_TYPE = 'aggregate'\n    CALLBACK_NAME = 'syslog_json'\n    CALLBACK_NEEDS_WHITELIST = True\n\n    def __init__(self):\n\n        super(CallbackModule, self).__init__()\n\n        self.logger =  logging.getLogger('ansible logger')\n        self.logger.setLevel(logging.DEBUG)\n\n        self.handler = logging.handlers.SysLogHandler(\n            address = (os.getenv('SYSLOG_SERVER','localhost'),\n                       os.getenv('SYSLOG_PORT',514)),\n            facility= os.getenv('SYSLOG_FACILITY',logging.handlers.SysLogHandler.LOG_USER)\n        )\n        self.logger.addHandler(self.handler)\n        self.hostname = socket.gethostname()\n\n\n    def runner_on_failed(self, host, res, ignore_errors=False):\n        self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_ok(self, host, res):\n        self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_skipped(self, host, item=None):\n        self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s' % (self.hostname,host, 'skipped'))\n\n    def runner_on_unreachable(self, host, res):\n        self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_async_failed(self, host, res, jid):\n        self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def playbook_on_import_for_host(self, host, imported_file):\n        self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: imported file %s' % (self.hostname,host,imported_file))\n\n    def playbook_on_not_import_for_host(self, host, missing_file):\n        self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: missing file %s' % (self.hostname,host,missing_file))\n", "path": "lib/ansible/plugins/callback/syslog_json.py"}], "after_files": [{"content": "# Make coding more python3-ish\nfrom __future__ import (absolute_import, division, print_function)\n__metaclass__ = type\n\nimport os\nimport json\n\nimport logging\nimport logging.handlers\n\nimport socket\n\nfrom ansible.plugins.callback import CallbackBase\n\nclass CallbackModule(CallbackBase):\n    \"\"\"\n    logs ansible-playbook and ansible runs to a syslog server in json format\n    make sure you have in ansible.cfg:\n        callback_plugins   = <path_to_callback_plugins_folder>\n    and put the plugin in <path_to_callback_plugins_folder>\n\n    This plugin makes use of the following environment variables:\n        SYSLOG_SERVER   (optional): defaults to localhost\n        SYSLOG_PORT     (optional): defaults to 514\n        SYSLOG_FACILITY (optional): defaults to user\n    \"\"\"\n    CALLBACK_VERSION = 2.0\n    CALLBACK_TYPE = 'aggregate'\n    CALLBACK_NAME = 'syslog_json'\n    CALLBACK_NEEDS_WHITELIST = True\n\n    def __init__(self):\n\n        super(CallbackModule, self).__init__()\n\n        self.logger =  logging.getLogger('ansible logger')\n        self.logger.setLevel(logging.DEBUG)\n\n        self.handler = logging.handlers.SysLogHandler(\n            address = (os.getenv('SYSLOG_SERVER','localhost'),\n                       int(os.getenv('SYSLOG_PORT',514))),\n            facility= os.getenv('SYSLOG_FACILITY',logging.handlers.SysLogHandler.LOG_USER)\n        )\n        self.logger.addHandler(self.handler)\n        self.hostname = socket.gethostname()\n\n\n    def runner_on_failed(self, host, res, ignore_errors=False):\n        self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_ok(self, host, res):\n        self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_skipped(self, host, item=None):\n        self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s' % (self.hostname,host, 'skipped'))\n\n    def runner_on_unreachable(self, host, res):\n        self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def runner_on_async_failed(self, host, res, jid):\n        self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,self._dump_results(res)))\n\n    def playbook_on_import_for_host(self, host, imported_file):\n        self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: imported file %s' % (self.hostname,host,imported_file))\n\n    def playbook_on_not_import_for_host(self, host, missing_file):\n        self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: missing file %s' % (self.hostname,host,missing_file))\n", "path": "lib/ansible/plugins/callback/syslog_json.py"}]}