Sign in

Tailing the activity log

lib/MT/App/CMS.pm:

366a367 > @log = @log[-20..-1] if $app->{query}->param('tail');

tmpl/cms/list_blog.tmpl:

222a223,231 > > <tr> > <td width="36"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=view_log&tail=1"><img src="<TMPL_VAR NAME=STATIC_URI>images/activity-icon.gif" width="36" height="32" border="0"></a></td> > <td width="164"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=view_log&tail=1"><font class="command"><MT_TRANS phrase="Tail Activity Log"></a><br><font class="instructional"><MT_TRANS phrase="Last 20 activity log entries"></font></td> > </tr> > > <tr> > <td colspan="2"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="15"></td> > </tr>

tmpl/cms/edit_entry.tmpl:

109c109 < window.location = '<TMPL_VAR NAME=SCRIPT_URL>?__mode=view_log#last'; --- > window.location = '<TMPL_VAR NAME=SCRIPT_URL>?__mode=view_log&tail=1#last';

Here's another change. This one will keep MT from reporting errors if the only problem was the weblogs.com ping timed out.

2421,2422c2421,2424 < $has_errors++, $app->log("Ping '$res->{url}' failed: $res->{error}") < unless $res->{good}; --- > unless($res->{good}) { > $app->log("Ping '$res->{url}' failed: $res->{error}"); > $has_errors++ unless $res->{url} eq 'http://rpc.weblogs.com/RPC2' && $res->{error} eq 'HTTP error: 500 read timeout'; > };

Phil Ringnalda 10:03 PM 2 May 2004

Well, this has been working wonderfully for me, for quite a while now. I log quite a few things, like attempts to post comments without previewing, to see what the spammers are up to without actually accepting their spam, and when I just need to see "sorry, we only accept one ping every half hour" I don't have to see the whole thing. Very nice. Until today, when I wanted to get something out of the full log for the first time in a while. Out of memory error. Huh. Might need to add in a paged interface, too. (Or would that incur the same "trying to load every entry at once" problem that the full page is hitting?)

Mark Paschal 7:05 PM 3 May 2004

If tailing still works, then it can load all the log entries into memory; the code change above actually lets MT load all the entries, then drops all but the last 20 before displaying. I guess the out of memory must be when it's trying to build the response page, in which case paginating should still work. For that matter, this was quite a while ago, and I bet I could make a better change that doesn't load all the entries at all, nowadays...