prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  output_localsyslog exceptions.KeyError: 'isError'
  After pulling the most recent version of cowrie to some of my honeypots, I get this error when a new connection I enabled [output_localsyslog] with configuration below:
  ```
  [output_localsyslog]
  enabled = true
  facility = LOCAL5
  format = text
  ```
  The log error shows this:
  ```
  2018-10-11T18:29:01.778300+0000 [twisted.logger._observer#critical] Temporarily disabling observer LegacyLogObserverWrapper(<bound method Output.emit of <cowrie.output.localsyslog.Output object at 0xb55ae7b0>>) due to exception: [Failure instance: Traceback: <type 'exceptions.KeyError'>: 'isError'
  	/opt/cowrie/src/cowrie/core/checkers.py:110:checkUserPass
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/threadable.py:53:sync
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/log.py:286:msg
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:154:publishToNewObserver
  	--- <exception caught here> ---
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_observer.py:131:__call__
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:93:__call__
  	/opt/cowrie/src/cowrie/core/output.py:209:emit
  	/opt/cowrie/src/cowrie/output/localsyslog.py:65:write
  	/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/syslog.py:76:emit
  	]
  	Traceback (most recent call last):
  	  File "/opt/cowrie/src/cowrie/core/checkers.py", line 110, in checkUserPass
  	    password=thepassword)
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/threadable.py", line 53, in sync
  	    return function(self, *args, **kwargs)
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/log.py", line 286, in msg
  	    _publishNew(self._publishPublisher, actualEventDict, textFromEventDict)
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py", line 154, in publishToNewObserver
  	    observer(eventDict)
  	--- <exception caught here> ---
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_observer.py", line 131, in __call__
  	    observer(event)
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py", line 93, in __call__
  	    self.legacyObserver(event)
  	  File "/opt/cowrie/src/cowrie/core/output.py", line 209, in emit
  	    self.write(ev)
  	  File "/opt/cowrie/src/cowrie/output/localsyslog.py", line 65, in write
  	    self.syslog.emit(logentry)
  	  File "/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/syslog.py", line 76, in emit
  	    if eventDict['isError']:
  	exceptions.KeyError: 'isError'
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cowrie/output/localsyslog.py`
  Content:
  ```
  1 # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
  2 # All rights reserved.
  3 #
  4 # Redistribution and use in source and binary forms, with or without
  5 # modification, are permitted provided that the following conditions
  6 # are met:
  7 #
  8 # 1. Redistributions of source code must retain the above copyright
  9 #    notice, this list of conditions and the following disclaimer.
  10 # 2. Redistributions in binary form must reproduce the above copyright
  11 #    notice, this list of conditions and the following disclaimer in the
  12 #    documentation and/or other materials provided with the distribution.
  13 # 3. The names of the author(s) may not be used to endorse or promote
  14 #    products derived from this software without specific prior written
  15 #    permission.
  16 #
  17 # THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  22 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  24 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27 # SUCH DAMAGE.
  28 
  29 from __future__ import absolute_import, division
  30 
  31 import syslog
  32 
  33 import twisted.python.syslog
  34 
  35 import cowrie.core.cef
  36 import cowrie.core.output
  37 from cowrie.core.config import CONFIG
  38 
  39 
  40 class Output(cowrie.core.output.Output):
  41 
  42     def __init__(self):
  43         facilityString = CONFIG.get('output_localsyslog', 'facility')
  44         self.format = CONFIG.get('output_localsyslog', 'format')
  45         self.facility = vars(syslog)['LOG_' + facilityString]
  46         self.syslog = twisted.python.syslog.SyslogObserver(prefix='cowrie', facility=self.facility)
  47         cowrie.core.output.Output.__init__(self)
  48 
  49     def start(self):
  50         pass
  51 
  52     def stop(self):
  53         pass
  54 
  55     def write(self, logentry):
  56         if self.format == 'cef':
  57             self.syslog.emit({
  58                 'message': cowrie.core.cef.formatCef(logentry),
  59                 'isError': False,
  60                 'system': 'cowrie'
  61             })
  62         else:
  63             # message appears with additional spaces if message key is defined
  64             logentry['message'] = [logentry['message']]
  65             self.syslog.emit(logentry)
  66
  ```
  --- 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/src/cowrie/output/localsyslog.py b/src/cowrie/output/localsyslog.py
  --- a/src/cowrie/output/localsyslog.py
  +++ b/src/cowrie/output/localsyslog.py
  @@ -53,6 +53,9 @@
           pass
   
       def write(self, logentry):
  +        if 'isError' not in logentry:
  +            logentry['isError'] = False
  +
           if self.format == 'cef':
               self.syslog.emit({
                   'message': cowrie.core.cef.formatCef(logentry),
  
verification_info: {"golden_diff": "diff --git a/src/cowrie/output/localsyslog.py b/src/cowrie/output/localsyslog.py\n--- a/src/cowrie/output/localsyslog.py\n+++ b/src/cowrie/output/localsyslog.py\n@@ -53,6 +53,9 @@\n         pass\n \n     def write(self, logentry):\n+        if 'isError' not in logentry:\n+            logentry['isError'] = False\n+\n         if self.format == 'cef':\n             self.syslog.emit({\n                 'message': cowrie.core.cef.formatCef(logentry),\n", "issue": "output_localsyslog exceptions.KeyError: 'isError'\nAfter pulling the most recent version of cowrie to some of my honeypots, I get this error when a new connection I enabled [output_localsyslog] with configuration below:\r\n```\r\n[output_localsyslog]\r\nenabled = true\r\nfacility = LOCAL5\r\nformat = text\r\n```\r\nThe log error shows this:\r\n```\r\n2018-10-11T18:29:01.778300+0000 [twisted.logger._observer#critical] Temporarily disabling observer LegacyLogObserverWrapper(<bound method Output.emit of <cowrie.output.localsyslog.Output object at 0xb55ae7b0>>) due to exception: [Failure instance: Traceback: <type 'exceptions.KeyError'>: 'isError'\r\n\t/opt/cowrie/src/cowrie/core/checkers.py:110:checkUserPass\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/threadable.py:53:sync\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/log.py:286:msg\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:154:publishToNewObserver\r\n\t--- <exception caught here> ---\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_observer.py:131:__call__\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py:93:__call__\r\n\t/opt/cowrie/src/cowrie/core/output.py:209:emit\r\n\t/opt/cowrie/src/cowrie/output/localsyslog.py:65:write\r\n\t/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/syslog.py:76:emit\r\n\t]\r\n\tTraceback (most recent call last):\r\n\t  File \"/opt/cowrie/src/cowrie/core/checkers.py\", line 110, in checkUserPass\r\n\t    password=thepassword)\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/threadable.py\", line 53, in sync\r\n\t    return function(self, *args, **kwargs)\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/log.py\", line 286, in msg\r\n\t    _publishNew(self._publishPublisher, actualEventDict, textFromEventDict)\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py\", line 154, in publishToNewObserver\r\n\t    observer(eventDict)\r\n\t--- <exception caught here> ---\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_observer.py\", line 131, in __call__\r\n\t    observer(event)\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/logger/_legacy.py\", line 93, in __call__\r\n\t    self.legacyObserver(event)\r\n\t  File \"/opt/cowrie/src/cowrie/core/output.py\", line 209, in emit\r\n\t    self.write(ev)\r\n\t  File \"/opt/cowrie/src/cowrie/output/localsyslog.py\", line 65, in write\r\n\t    self.syslog.emit(logentry)\r\n\t  File \"/opt/cowrie/cowrie-env/local/lib/python2.7/site-packages/twisted/python/syslog.py\", line 76, in emit\r\n\t    if eventDict['isError']:\r\n\texceptions.KeyError: 'isError'\r\n```\n", "before_files": [{"content": "# Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n#\n# 1. Redistributions of source code must retain the above copyright\n#    notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n#    notice, this list of conditions and the following disclaimer in the\n#    documentation and/or other materials provided with the distribution.\n# 3. The names of the author(s) may not be used to endorse or promote\n#    products derived from this software without specific prior written\n#    permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR\n# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n\nfrom __future__ import absolute_import, division\n\nimport syslog\n\nimport twisted.python.syslog\n\nimport cowrie.core.cef\nimport cowrie.core.output\nfrom cowrie.core.config import CONFIG\n\n\nclass Output(cowrie.core.output.Output):\n\n    def __init__(self):\n        facilityString = CONFIG.get('output_localsyslog', 'facility')\n        self.format = CONFIG.get('output_localsyslog', 'format')\n        self.facility = vars(syslog)['LOG_' + facilityString]\n        self.syslog = twisted.python.syslog.SyslogObserver(prefix='cowrie', facility=self.facility)\n        cowrie.core.output.Output.__init__(self)\n\n    def start(self):\n        pass\n\n    def stop(self):\n        pass\n\n    def write(self, logentry):\n        if self.format == 'cef':\n            self.syslog.emit({\n                'message': cowrie.core.cef.formatCef(logentry),\n                'isError': False,\n                'system': 'cowrie'\n            })\n        else:\n            # message appears with additional spaces if message key is defined\n            logentry['message'] = [logentry['message']]\n            self.syslog.emit(logentry)\n", "path": "src/cowrie/output/localsyslog.py"}], "after_files": [{"content": "# Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n#\n# 1. Redistributions of source code must retain the above copyright\n#    notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n#    notice, this list of conditions and the following disclaimer in the\n#    documentation and/or other materials provided with the distribution.\n# 3. The names of the author(s) may not be used to endorse or promote\n#    products derived from this software without specific prior written\n#    permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR\n# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n\nfrom __future__ import absolute_import, division\n\nimport syslog\n\nimport twisted.python.syslog\n\nimport cowrie.core.cef\nimport cowrie.core.output\nfrom cowrie.core.config import CONFIG\n\n\nclass Output(cowrie.core.output.Output):\n\n    def __init__(self):\n        facilityString = CONFIG.get('output_localsyslog', 'facility')\n        self.format = CONFIG.get('output_localsyslog', 'format')\n        self.facility = vars(syslog)['LOG_' + facilityString]\n        self.syslog = twisted.python.syslog.SyslogObserver(prefix='cowrie', facility=self.facility)\n        cowrie.core.output.Output.__init__(self)\n\n    def start(self):\n        pass\n\n    def stop(self):\n        pass\n\n    def write(self, logentry):\n        if 'isError' not in logentry:\n            logentry['isError'] = False\n\n        if self.format == 'cef':\n            self.syslog.emit({\n                'message': cowrie.core.cef.formatCef(logentry),\n                'isError': False,\n                'system': 'cowrie'\n            })\n        else:\n            # message appears with additional spaces if message key is defined\n            logentry['message'] = [logentry['message']]\n            self.syslog.emit(logentry)\n", "path": "src/cowrie/output/localsyslog.py"}]}