Changeset 499:63397d38a1aa
- 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
| r498 |
r499 |
|
| 1 | 1 | 2008-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 | |
|---|
| 2 | 11 | |
|---|
| 3 | 12 | * foolscap/logging/web.py: mark any incident triggers in the |
|---|
| r431 |
r499 |
|
| 208 | 208 | <h3>flogtool tail</h3> |
|---|
| 209 | 209 | |
|---|
| 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 |
|---|
| | 211 | following 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> |
|---|
| 212 | 221 | |
|---|
| 213 | 222 | <h3>log-gatherer</h3> |
|---|
| … | … | |
| 237 | 246 | the incident. This event will also be present somewhere in the rest of the |
|---|
| 238 | 247 | 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> |
|---|
| 239 | 255 | </ul> |
|---|
| 240 | 256 | |
|---|
| r495 |
r499 |
|
| 89 | 89 | "trigger": triggering_event, |
|---|
| 90 | 90 | "versions": app_versions.versions, |
|---|
| | 91 | "pid": os.getpid(), |
|---|
| 91 | 92 | }} |
|---|
| 92 | 93 | pickle.dump(header, self.f1) |
|---|
| r475 |
r499 |
|
| 20 | 20 | self.f = savefile |
|---|
| 21 | 21 | |
|---|
| 22 | | def emit_header(self, versions): |
|---|
| | 22 | def emit_header(self, versions, pid): |
|---|
| 23 | 23 | header = {"header": {"type": "tail", |
|---|
| 24 | 24 | "versions": versions}} |
|---|
| | 25 | if pid is not None: |
|---|
| | 26 | header["header"]["pid"] = pid |
|---|
| 25 | 27 | pickle.dump(header, self.f) |
|---|
| 26 | 28 | |
|---|
| … | … | |
| 72 | 74 | self.output = output |
|---|
| 73 | 75 | |
|---|
| 74 | | def got_versions(self, versions): |
|---|
| | 76 | def got_versions(self, versions, pid=None): |
|---|
| 75 | 77 | print >>self.output, "Remote Versions:" |
|---|
| 76 | 78 | for k in sorted(versions.keys()): |
|---|
| 77 | 79 | print >>self.output, " %s: %s" % (k, versions[k]) |
|---|
| 78 | 80 | if self.saver: |
|---|
| 79 | | self.saver.emit_header(versions) |
|---|
| | 81 | self.saver.emit_header(versions, pid) |
|---|
| 80 | 82 | |
|---|
| 81 | 83 | def remote_msg(self, d): |
|---|
| … | … | |
| 134 | 136 | if isinstance(pid_or_failure, int): |
|---|
| 135 | 137 | print "Connected (to pid %d)" % pid_or_failure |
|---|
| | 138 | return pid_or_failure |
|---|
| 136 | 139 | else: |
|---|
| 137 | 140 | # the logport is probably foolscap-0.2.8 or earlier and |
|---|
| 138 | 141 | # doesn't offer get_pid() |
|---|
| 139 | 142 | print "Connected (unable to get pid)" |
|---|
| | 143 | return None |
|---|
| 140 | 144 | d.addBoth(_announce) |
|---|
| 141 | 145 | publisher.notifyOnDisconnect(self._lost_logpublisher) |
|---|
| 142 | 146 | 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) |
|---|
| 145 | 152 | catch_up = bool(self.options["catch-up"]) |
|---|
| 146 | 153 | if catch_up: |
|---|