<div class="gmail_quote">On Wed, Nov 16, 2011 at 2:27 PM, Don Dwiggins <span dir="ltr">&lt;<a href="mailto:ddwiggins@advpubtech.com">ddwiggins@advpubtech.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<u></u>

  
    
  
  <div bgcolor="#ffffff" text="#000000">
    On 11/15/2011 8:57 AM, Christopher Armstrong wrote:
    <blockquote type="cite">
      <div class="gmail_quote">If you pass a &#39;system&#39; kwarg to log.msg
        then it will go in that field.
        <div><br>
        </div>
        <div>log.msg(&quot;hi&quot;, system=&quot;stuff&quot;) results in &lt;date&gt;
          [stuff] hi</div>
      </div>
    </blockquote>
    <br>
    This triggered me to look further into what LogPublisher.msg does,
    since I&#39;ve long wanted to customize the format of the output.  I
    found what I wanted in
    <a href="http://twistedmatrix.com/documents/current/api/twisted.python.log.ILogObserver.html" target="_blank">http://twistedmatrix.com/documents/current/api/twisted.python.log.ILogObserver.html</a>
    :<br>
    <br>
    In msg(), the message gets added to the kwargs dictionary (along
    with a timestamp called &#39;time&#39;), and that dict is passed to
    LogObserver.emit, which uses textFromEventDict() to create what&#39;s
    actually output.  This dictionary has the following keys recognized
    by textFromEventDict:<br>
    <ul>
      <li> <code>message</code>: A <code>tuple</code> of <code>str</code>
        containing messages to be logged. </li>
      <li> <code>system</code>: A <code>str</code> which indicates the
        &quot;system&quot; which is generating this event. </li>
      <li> <code>isError</code>: A <code>bool</code> indicating
        whether this event represents an error. </li>
      <li> <code>failure</code>: A <a href="http://twistedmatrix.com/documents/current/api/twisted.python.failure.Failure.html" target="_blank"><code>failure.Failure</code></a>
        instance, <span>required if the event is an error.</span>
      </li>
      <li> <code>why</code>: Used as header of the traceback in case of
        errors. </li>
      <li> <code>format</code>: A string format used in place of <code>message</code>
        to customize the event. The intent is for the observer to format
        a message by doing something like <code>format % eventDict</code>.
      </li>
    </ul>
    So, for example, you could do log.msg(format=&#39;....&#39;, foo=&#39;stuff&#39;,
    bar=&#39;things&#39;)<br>
    <br>
    I suggest that this be added to the documentation string of the
    msg() method and
    <a href="http://twistedmatrix.com/documents/current/core/howto/logging.html" target="_blank">http://twistedmatrix.com/documents/current/core/howto/logging.html</a>.<br><font color="#888888">
    <br>
    <br>
    <div>-- <br>
      <pre>Don Dwiggins
Advanced Publishing Technology
</pre>
    </div>
  </font></div><br></blockquote></div><br>Please open a ticket for this, so it doesn&#39;t get lost.<br><br>Thx.<br><br>Kevin Horn<br>