Changeset 499:63397d38a1aa

Show
Ignore:
Timestamp:
10/14/08 17:47:38 (3 months ago)
Author:
Brian Warner <warner@allmydata.com>
branch:
default
Message:

logfiles: include PID in 'flogtool tail' savefiles and incident reports. Part of #80.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ChangeLog

    r498 r499  
    112008-10-14  Brian Warner  <warner@allmydata.com> 
     2 
     3        * foolscap/logging/tail.py (LogTail): include the retrieved PID in 
     4        the saved logfile. Part of #80. 
     5        * foolscap/logging/incident.py (IncidentReporter.incident_declared): 
     6        also include the PID in the incident report's header. 
     7        * doc/specifications/logfiles.xhtml: document the ['versions'] 
     8        and ['pid'] fields in incident reports and the 'flogtool tail' 
     9        savefile. 
     10 
    211 
    312        * foolscap/logging/web.py: mark any incident triggers in the 
  • doc/specifications/logfiles.xhtml

    r431 r499  
    208208<h3>flogtool tail</h3> 
    209209 
    210 <p>The header dict produced by <code>flogtool tail</code> does not contain 
    211 any additional keys at this time.</p> 
     210<p>The header dict produced by <code>flogtool tail</code> contains the 
     211following additional keys:</p> 
     212 
     213<ul> 
     214  <li><code>pid</code> (int): if present, this value contains the process id 
     215  of the process which was being followed by 'flogtool tail'.</li> 
     216 
     217  <li><code>versions</code> (dict): this contains a dictionary of component 
     218  versions, mapping a string component name like "foolscap" to a version 
     219  string.</li> 
     220</ul> 
    212221 
    213222<h3>log-gatherer</h3> 
     
    237246  the incident. This event will also be present somewhere in the rest of the 
    238247  logfile, at its normal position in the event stream. </li> 
     248 
     249  <li><code>pid</code> (int): this value contains the process id of the 
     250  process which experienced the incident.</li> 
     251 
     252  <li><code>versions</code> (dict): this contains a dictionary of component 
     253  versions, mapping a string component name like "foolscap" to a version 
     254  string.</li> 
    239255</ul> 
    240256 
  • foolscap/logging/incident.py

    r495 r499  
    8989                             "trigger": triggering_event, 
    9090                             "versions": app_versions.versions, 
     91                             "pid": os.getpid(), 
    9192                             }} 
    9293        pickle.dump(header, self.f1) 
  • foolscap/logging/tail.py

    r475 r499  
    2020        self.f = savefile 
    2121 
    22     def emit_header(self, versions): 
     22    def emit_header(self, versions, pid): 
    2323        header = {"header": {"type": "tail", 
    2424                             "versions": versions}} 
     25        if pid is not None: 
     26            header["header"]["pid"] = pid 
    2527        pickle.dump(header, self.f) 
    2628 
     
    7274        self.output = output 
    7375 
    74     def got_versions(self, versions): 
     76    def got_versions(self, versions, pid=None): 
    7577        print >>self.output, "Remote Versions:" 
    7678        for k in sorted(versions.keys()): 
    7779            print >>self.output, " %s: %s" % (k, versions[k]) 
    7880        if self.saver: 
    79             self.saver.emit_header(versions
     81            self.saver.emit_header(versions, pid
    8082 
    8183    def remote_msg(self, d): 
     
    134136            if isinstance(pid_or_failure, int): 
    135137                print "Connected (to pid %d)" % pid_or_failure 
     138                return pid_or_failure 
    136139            else: 
    137140                # the logport is probably foolscap-0.2.8 or earlier and 
    138141                # doesn't offer get_pid() 
    139142                print "Connected (unable to get pid)" 
     143                return None 
    140144        d.addBoth(_announce) 
    141145        publisher.notifyOnDisconnect(self._lost_logpublisher) 
    142146        lp = LogPrinter(self.options, target_tubid) 
    143         d.addCallback(lambda res: publisher.callRemote("get_versions")) 
    144         d.addCallback(lp.got_versions) 
     147        def _ask_for_versions(pid): 
     148            d = publisher.callRemote("get_versions") 
     149            d.addCallback(lp.got_versions, pid) 
     150            return d 
     151        d.addCallback(_ask_for_versions) 
    145152        catch_up = bool(self.options["catch-up"]) 
    146153        if catch_up: