prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Make exception tracebacks default
  Instead of asking the user to run coala with `-L DEBUG`
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `coalib/output/printers/LogPrinter.py`
  Content:
  ```
  1 import traceback
  2 
  3 from pyprint.ColorPrinter import ColorPrinter
  4 
  5 from coalib.output.printers.LOG_LEVEL import LOG_LEVEL, LOG_LEVEL_COLORS
  6 from coalib.processes.communication.LogMessage import LogMessage
  7 
  8 
  9 class LogPrinter:
  10     """
  11     The LogPrinter class allows to print log messages to an underlying Printer.
  12 
  13     This class is an adapter, means you can create a LogPrinter from every
  14     existing Printer instance.
  15     """
  16 
  17     def __init__(self,
  18                  printer,
  19                  log_level=LOG_LEVEL.INFO,
  20                  timestamp_format="%X"):
  21         """
  22         Creates a new log printer from an existing Printer.
  23 
  24         :param printer:          The underlying Printer where log messages
  25                                  shall be written to. If you inherit from
  26                                  LogPrinter, set it to self.
  27         :param log_level:        The minimum log level, everything below will
  28                                  not be logged.
  29         :param timestamp_format: The format string for the
  30                                  datetime.today().strftime(format) method.
  31         """
  32         self._printer = printer
  33         self.log_level = log_level
  34         self.timestamp_format = timestamp_format
  35 
  36     @property
  37     def printer(self):
  38         """
  39         Returns the underlying printer where logs are printed to.
  40         """
  41         return self._printer
  42 
  43     def _get_log_prefix(self, log_level, timestamp):
  44         datetime_string = timestamp.strftime(self.timestamp_format)
  45 
  46         if datetime_string != "":
  47             datetime_string = "[" + datetime_string + "]"
  48 
  49         return '[{}]{}'.format(LOG_LEVEL.reverse.get(log_level, "ERROR"),
  50                                datetime_string)
  51 
  52     def debug(self, *messages, delimiter=" ", timestamp=None, **kwargs):
  53         self.log_message(LogMessage(LOG_LEVEL.DEBUG,
  54                                     *messages,
  55                                     delimiter=delimiter,
  56                                     timestamp=timestamp),
  57                          **kwargs)
  58 
  59     def info(self, *messages, delimiter=" ", timestamp=None, **kwargs):
  60         self.log_message(LogMessage(LOG_LEVEL.INFO,
  61                                     *messages,
  62                                     delimiter=delimiter,
  63                                     timestamp=timestamp),
  64                          **kwargs)
  65 
  66     def warn(self, *messages, delimiter=" ", timestamp=None, **kwargs):
  67         self.log_message(LogMessage(LOG_LEVEL.WARNING,
  68                                     *messages,
  69                                     delimiter=delimiter,
  70                                     timestamp=timestamp),
  71                          **kwargs)
  72 
  73     def err(self, *messages, delimiter=" ", timestamp=None, **kwargs):
  74         self.log_message(LogMessage(LOG_LEVEL.ERROR,
  75                                     *messages,
  76                                     delimiter=delimiter,
  77                                     timestamp=timestamp),
  78                          **kwargs)
  79 
  80     def log(self, log_level, message, timestamp=None, **kwargs):
  81         self.log_message(LogMessage(log_level,
  82                                     message,
  83                                     timestamp=timestamp),
  84                          **kwargs)
  85 
  86     def log_exception(self,
  87                       message,
  88                       exception,
  89                       log_level=LOG_LEVEL.ERROR,
  90                       timestamp=None,
  91                       **kwargs):
  92         """
  93         If the log_level of the printer is greater than DEBUG, it prints
  94         only the message. If it is DEBUG or lower, it shows the message
  95         along with the traceback of the exception.
  96 
  97         :param message:   The message to print.
  98         :param exception: The exception to print.
  99         :param log_level: The log_level of this message (not used when
  100                           logging the traceback. Tracebacks always have
  101                           a level of DEBUG).
  102         :param timestamp: The time at which this log occurred. Defaults to
  103                           the current time.
  104         :param kwargs:    Keyword arguments to be passed when logging the
  105                           message (not used when logging the traceback).
  106         """
  107         if not isinstance(exception, BaseException):
  108             raise TypeError("log_exception can only log derivatives of "
  109                             "BaseException.")
  110 
  111         traceback_str = "\n".join(
  112             traceback.format_exception(type(exception),
  113                                        exception,
  114                                        exception.__traceback__))
  115 
  116         self.log(log_level, message, timestamp=timestamp, **kwargs)
  117         self.log_message(
  118             LogMessage(LOG_LEVEL.DEBUG,
  119                        "Exception was:" + "\n" + traceback_str,
  120                        timestamp=timestamp),
  121             **kwargs)
  122 
  123     def log_message(self, log_message, **kwargs):
  124         if not isinstance(log_message, LogMessage):
  125             raise TypeError("log_message should be of type LogMessage.")
  126 
  127         if log_message.log_level < self.log_level:
  128             return
  129 
  130         self._print_log_message(
  131             self._get_log_prefix(log_message.log_level, log_message.timestamp),
  132             log_message,
  133             **kwargs)
  134 
  135     def _print_log_message(self, prefix, log_message, **kwargs):
  136         """
  137         Override this if you want to influence how the log message is printed.
  138 
  139         If the underlying printer is a ColorPrinter, then colored logging is
  140         used. You can turn it off in the underlying ColorPrinter if you want to
  141         print uncolored.
  142 
  143         :param prefix:      The prefix to print (as string).
  144         :param log_message: The LogMessage object to print.
  145         :param kwargs:      Any other keyword arguments.
  146         """
  147         if isinstance(self._printer, ColorPrinter):
  148             self.printer.print(prefix,
  149                                end=" ",
  150                                color=LOG_LEVEL_COLORS[log_message.log_level],
  151                                **kwargs)
  152             self.printer.print(log_message.message, **kwargs)
  153         else:
  154             self.printer.print(prefix, log_message.message, **kwargs)
  155
  ```
  --- 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/coalib/output/printers/LogPrinter.py b/coalib/output/printers/LogPrinter.py
  --- a/coalib/output/printers/LogPrinter.py
  +++ b/coalib/output/printers/LogPrinter.py
  @@ -115,7 +115,7 @@
   
           self.log(log_level, message, timestamp=timestamp, **kwargs)
           self.log_message(
  -            LogMessage(LOG_LEVEL.DEBUG,
  +            LogMessage(LOG_LEVEL.INFO,
                          "Exception was:" + "\n" + traceback_str,
                          timestamp=timestamp),
               **kwargs)
  
verification_info: {"golden_diff": "diff --git a/coalib/output/printers/LogPrinter.py b/coalib/output/printers/LogPrinter.py\n--- a/coalib/output/printers/LogPrinter.py\n+++ b/coalib/output/printers/LogPrinter.py\n@@ -115,7 +115,7 @@\n \n         self.log(log_level, message, timestamp=timestamp, **kwargs)\n         self.log_message(\n-            LogMessage(LOG_LEVEL.DEBUG,\n+            LogMessage(LOG_LEVEL.INFO,\n                        \"Exception was:\" + \"\\n\" + traceback_str,\n                        timestamp=timestamp),\n             **kwargs)\n", "issue": "Make exception tracebacks default\nInstead of asking the user to run coala with `-L DEBUG`\n\n", "before_files": [{"content": "import traceback\n\nfrom pyprint.ColorPrinter import ColorPrinter\n\nfrom coalib.output.printers.LOG_LEVEL import LOG_LEVEL, LOG_LEVEL_COLORS\nfrom coalib.processes.communication.LogMessage import LogMessage\n\n\nclass LogPrinter:\n    \"\"\"\n    The LogPrinter class allows to print log messages to an underlying Printer.\n\n    This class is an adapter, means you can create a LogPrinter from every\n    existing Printer instance.\n    \"\"\"\n\n    def __init__(self,\n                 printer,\n                 log_level=LOG_LEVEL.INFO,\n                 timestamp_format=\"%X\"):\n        \"\"\"\n        Creates a new log printer from an existing Printer.\n\n        :param printer:          The underlying Printer where log messages\n                                 shall be written to. If you inherit from\n                                 LogPrinter, set it to self.\n        :param log_level:        The minimum log level, everything below will\n                                 not be logged.\n        :param timestamp_format: The format string for the\n                                 datetime.today().strftime(format) method.\n        \"\"\"\n        self._printer = printer\n        self.log_level = log_level\n        self.timestamp_format = timestamp_format\n\n    @property\n    def printer(self):\n        \"\"\"\n        Returns the underlying printer where logs are printed to.\n        \"\"\"\n        return self._printer\n\n    def _get_log_prefix(self, log_level, timestamp):\n        datetime_string = timestamp.strftime(self.timestamp_format)\n\n        if datetime_string != \"\":\n            datetime_string = \"[\" + datetime_string + \"]\"\n\n        return '[{}]{}'.format(LOG_LEVEL.reverse.get(log_level, \"ERROR\"),\n                               datetime_string)\n\n    def debug(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.DEBUG,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def info(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.INFO,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def warn(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.WARNING,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def err(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.ERROR,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def log(self, log_level, message, timestamp=None, **kwargs):\n        self.log_message(LogMessage(log_level,\n                                    message,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def log_exception(self,\n                      message,\n                      exception,\n                      log_level=LOG_LEVEL.ERROR,\n                      timestamp=None,\n                      **kwargs):\n        \"\"\"\n        If the log_level of the printer is greater than DEBUG, it prints\n        only the message. If it is DEBUG or lower, it shows the message\n        along with the traceback of the exception.\n\n        :param message:   The message to print.\n        :param exception: The exception to print.\n        :param log_level: The log_level of this message (not used when\n                          logging the traceback. Tracebacks always have\n                          a level of DEBUG).\n        :param timestamp: The time at which this log occurred. Defaults to\n                          the current time.\n        :param kwargs:    Keyword arguments to be passed when logging the\n                          message (not used when logging the traceback).\n        \"\"\"\n        if not isinstance(exception, BaseException):\n            raise TypeError(\"log_exception can only log derivatives of \"\n                            \"BaseException.\")\n\n        traceback_str = \"\\n\".join(\n            traceback.format_exception(type(exception),\n                                       exception,\n                                       exception.__traceback__))\n\n        self.log(log_level, message, timestamp=timestamp, **kwargs)\n        self.log_message(\n            LogMessage(LOG_LEVEL.DEBUG,\n                       \"Exception was:\" + \"\\n\" + traceback_str,\n                       timestamp=timestamp),\n            **kwargs)\n\n    def log_message(self, log_message, **kwargs):\n        if not isinstance(log_message, LogMessage):\n            raise TypeError(\"log_message should be of type LogMessage.\")\n\n        if log_message.log_level < self.log_level:\n            return\n\n        self._print_log_message(\n            self._get_log_prefix(log_message.log_level, log_message.timestamp),\n            log_message,\n            **kwargs)\n\n    def _print_log_message(self, prefix, log_message, **kwargs):\n        \"\"\"\n        Override this if you want to influence how the log message is printed.\n\n        If the underlying printer is a ColorPrinter, then colored logging is\n        used. You can turn it off in the underlying ColorPrinter if you want to\n        print uncolored.\n\n        :param prefix:      The prefix to print (as string).\n        :param log_message: The LogMessage object to print.\n        :param kwargs:      Any other keyword arguments.\n        \"\"\"\n        if isinstance(self._printer, ColorPrinter):\n            self.printer.print(prefix,\n                               end=\" \",\n                               color=LOG_LEVEL_COLORS[log_message.log_level],\n                               **kwargs)\n            self.printer.print(log_message.message, **kwargs)\n        else:\n            self.printer.print(prefix, log_message.message, **kwargs)\n", "path": "coalib/output/printers/LogPrinter.py"}], "after_files": [{"content": "import traceback\n\nfrom pyprint.ColorPrinter import ColorPrinter\n\nfrom coalib.output.printers.LOG_LEVEL import LOG_LEVEL, LOG_LEVEL_COLORS\nfrom coalib.processes.communication.LogMessage import LogMessage\n\n\nclass LogPrinter:\n    \"\"\"\n    The LogPrinter class allows to print log messages to an underlying Printer.\n\n    This class is an adapter, means you can create a LogPrinter from every\n    existing Printer instance.\n    \"\"\"\n\n    def __init__(self,\n                 printer,\n                 log_level=LOG_LEVEL.INFO,\n                 timestamp_format=\"%X\"):\n        \"\"\"\n        Creates a new log printer from an existing Printer.\n\n        :param printer:          The underlying Printer where log messages\n                                 shall be written to. If you inherit from\n                                 LogPrinter, set it to self.\n        :param log_level:        The minimum log level, everything below will\n                                 not be logged.\n        :param timestamp_format: The format string for the\n                                 datetime.today().strftime(format) method.\n        \"\"\"\n        self._printer = printer\n        self.log_level = log_level\n        self.timestamp_format = timestamp_format\n\n    @property\n    def printer(self):\n        \"\"\"\n        Returns the underlying printer where logs are printed to.\n        \"\"\"\n        return self._printer\n\n    def _get_log_prefix(self, log_level, timestamp):\n        datetime_string = timestamp.strftime(self.timestamp_format)\n\n        if datetime_string != \"\":\n            datetime_string = \"[\" + datetime_string + \"]\"\n\n        return '[{}]{}'.format(LOG_LEVEL.reverse.get(log_level, \"ERROR\"),\n                               datetime_string)\n\n    def debug(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.DEBUG,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def info(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.INFO,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def warn(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.WARNING,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def err(self, *messages, delimiter=\" \", timestamp=None, **kwargs):\n        self.log_message(LogMessage(LOG_LEVEL.ERROR,\n                                    *messages,\n                                    delimiter=delimiter,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def log(self, log_level, message, timestamp=None, **kwargs):\n        self.log_message(LogMessage(log_level,\n                                    message,\n                                    timestamp=timestamp),\n                         **kwargs)\n\n    def log_exception(self,\n                      message,\n                      exception,\n                      log_level=LOG_LEVEL.ERROR,\n                      timestamp=None,\n                      **kwargs):\n        \"\"\"\n        If the log_level of the printer is greater than DEBUG, it prints\n        only the message. If it is DEBUG or lower, it shows the message\n        along with the traceback of the exception.\n\n        :param message:   The message to print.\n        :param exception: The exception to print.\n        :param log_level: The log_level of this message (not used when\n                          logging the traceback. Tracebacks always have\n                          a level of DEBUG).\n        :param timestamp: The time at which this log occurred. Defaults to\n                          the current time.\n        :param kwargs:    Keyword arguments to be passed when logging the\n                          message (not used when logging the traceback).\n        \"\"\"\n        if not isinstance(exception, BaseException):\n            raise TypeError(\"log_exception can only log derivatives of \"\n                            \"BaseException.\")\n\n        traceback_str = \"\\n\".join(\n            traceback.format_exception(type(exception),\n                                       exception,\n                                       exception.__traceback__))\n\n        self.log(log_level, message, timestamp=timestamp, **kwargs)\n        self.log_message(\n            LogMessage(LOG_LEVEL.INFO,\n                       \"Exception was:\" + \"\\n\" + traceback_str,\n                       timestamp=timestamp),\n            **kwargs)\n\n    def log_message(self, log_message, **kwargs):\n        if not isinstance(log_message, LogMessage):\n            raise TypeError(\"log_message should be of type LogMessage.\")\n\n        if log_message.log_level < self.log_level:\n            return\n\n        self._print_log_message(\n            self._get_log_prefix(log_message.log_level, log_message.timestamp),\n            log_message,\n            **kwargs)\n\n    def _print_log_message(self, prefix, log_message, **kwargs):\n        \"\"\"\n        Override this if you want to influence how the log message is printed.\n\n        If the underlying printer is a ColorPrinter, then colored logging is\n        used. You can turn it off in the underlying ColorPrinter if you want to\n        print uncolored.\n\n        :param prefix:      The prefix to print (as string).\n        :param log_message: The LogMessage object to print.\n        :param kwargs:      Any other keyword arguments.\n        \"\"\"\n        if isinstance(self._printer, ColorPrinter):\n            self.printer.print(prefix,\n                               end=\" \",\n                               color=LOG_LEVEL_COLORS[log_message.log_level],\n                               **kwargs)\n            self.printer.print(log_message.message, **kwargs)\n        else:\n            self.printer.print(prefix, log_message.message, **kwargs)\n", "path": "coalib/output/printers/LogPrinter.py"}]}