Commons Logging
  1. Commons Logging
  2. LOGGING-86

[logging] SimpleLog log method should defer writing for better reuse!

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.0.4
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      SimpleLog 'log' method which performs the actual log write to System.err should
      be refactored to instead call a 'doWrite' method which commits the log message
      to the stream. This would allow subclasses to reuse the bulk of the SimpleLog
      logic but direct the output elsewhere (in my case, for instance, a GUI log
      window). This change is too trivial to mandate a full patch, here is a pseudo
      patch:

      /**

      • <p> Do the actual logging.
      • This method assembles the message
      • and then prints to <code>System.err</code>.</p>
        */
        protected void log(int type, Object message, Throwable t) { ... // print to System.err - System.err.println(buf.toString()); + doWrite(buf); }

      + /** Subclasses can easily override this */
      + protected void doWrite(StringBuffer buf)

      { + System.err.println(buf); + }

      Without this patch, the only current solution is reuse by cutting-and-pasting
      the entire 'log' method and changing the single System.err line

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Aaron Hamid
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development