Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-223

Make sys.stdout/sys.stderr log properly to Apache error logs.

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.3.1
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      When sys.stderr or sys.stdout are written to directly, or when the 'print' statement is used without a target file object, any text output will make it into the Apache error log files, but it will only get there after a flush has been performed on stdout/stderr. Most of the time the streams will only be flushed when Apache is being shutdown with the result being that the output is far removed in the log file from any other messages that may have been logged at the same time using the normal Apache error logging functions. Further, anything output via stdout/stderr does not have associated with it the error log prefix giving the time the output was generated.

      All this can be improved by replacing sys.stderr and sys.stdout with custom Python objects which buffer any output and flushing it through to the Apache error log using the proper ap_log_error() function after each newline is encountered. This will mean that output appears straight away as soon as newline sent and output will be prefixed with date/time string.

      Do note though that the output cannot be associated with a specific virtual host and thus would go to the main Apache error log file even if each virtual host has its own log file. This is the same as now though when sys.stderr and sys.stdout are used.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              grahamd Graham Phillip Dumpleton
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: