# HG changeset patch # User igor@chub.in # Date 1245708902 -10800 # Node ID 822b36252d7fd11f9933f16a0e321bfa2541523b # Parent 40d8433955474ccfbc9284d86a66cc034c8eaad0 Вывод больших фрагментов текста не теряется. Большие фрагменты текста теперь не вырезаются бесследно. Там, откуда они вырезаются, вставляются ссылки, по которым можно посмотреть полную версию вывода. Испытано на больших фрагментах текста, содержащих до 5000 строк (фрагменты более 5000 строк по умолчанию обрезаются административно; допустимые размеры задаются в l3config.pm). Исправлены ошибки, из-за которых большие фрагменты обрабатывались некорректно. diff -r 40d843395547 -r 822b36252d7f l3-agent --- a/l3-agent Fri Mar 06 13:34:59 2009 +0600 +++ b/l3-agent Tue Jun 23 01:15:02 2009 +0300 @@ -344,6 +344,7 @@ my $tty = $1; my %cl; my $last_output_length=0; + my $saved_output; while () { $commandlines_processed++; @@ -555,6 +556,7 @@ # Output if (!$last_cl{"suppress_output"} || $last_cl{"err"}) { + $last_cl{"output"}=$saved_output; for (my $i=0; $i<$Config{"terminal_height"}; $i++) { my $line= $vt{$local_session_id}->row_plaintext($i); next if !defined ($line) ; #|| $line =~ /^\s*$/; @@ -568,6 +570,7 @@ } $vt{$local_session_id}->reset(); + $saved_output=""; # Changing encoding @@ -588,6 +591,20 @@ next; } + if (($commandlines_processed%100) == 0) { +# Каждые сто строк обнуляем терминал и переносим вывод из него в кэш + # Output + for (my $i=0; $i<$Config{"terminal_height"}; $i++) { + my $line= $vt{$local_session_id}->row_plaintext($i); + next if !defined ($line) ; #|| $line =~ /^\s*$/; + $line =~ s/\s*$//; + $line .= "\n" unless $line =~ /^\s*$/; + $saved_output .= $line; + } + $vt{$local_session_id}->reset(); + $last_output_length=0; + } + # Иначе, это строка вывода $last_output_length+=length($_); diff -r 40d843395547 -r 822b36252d7f l3-cgi-lite --- a/l3-cgi-lite Fri Mar 06 13:34:59 2009 +0600 +++ b/l3-cgi-lite Tue Jun 23 01:15:02 2009 +0300 @@ -6,7 +6,8 @@ BEGIN { chdir("/etc/lilalo/"); - require l3config; + require "/etc/lilalo/l3config.pm" + or die " Can't open l3config.pm "; l3config::init_config(); }; @@ -27,10 +28,12 @@ my $commands_to_show_at_a_go = $l3config::Config{"commands_to_show_at_a_go"}; my $start_from_command = "0"; my $this_page_number=0; +my $page_id; if ($path =~ s/:(.*)//) { $this_page_number = $1; $start_from_command = $this_page_number*$commands_to_show_at_a_go; } +$page_id=$this_page_number; my $real_path = $l3config::Config{"backend_datadir"} ; my $cgi_path = $l3config::Config{"cgi_path"} ; @@ -38,6 +41,10 @@ my $frontend_css = $l3config::Config{"frontend_css"} ; my $filter=$ENV{QUERY_STRING}; +if ($filter =~ s@command_id=([0-9]+)@@){ + $l3config::Config{"command_id"}=$1; + $page_id=$1; +} if ($filter =~ /page=([^&]*)/ ) { open(PAGE_NAME, "grep $1 $real_path/sessions-index | tail -1 | sed 's^-<.*^^; s^/[^/]*\$^^'| "); my $page_name; @@ -84,11 +91,18 @@ unless ( -e "$real_path/$data_file" && -e "$real_path/index.html" - && (stat("$real_path/index.html"))[9] > (stat("$real_path/$data_file"))[9] && 0!=0 ) { + && (stat("$real_path/index$page_id.html"))[9] > (stat("$real_path/$data_file"))[9]) { + my $fragment_options; + if ($l3config::Config{"command_id"}) { + $fragment_options = " --command_id ".$l3config::Config{"command_id"}; + } + else { + $fragment_options = " --start_from_command $start_from_command "; + } my $l3_frontend = "l3-frontend --backend_datafile $real_path/$data_file". - " --output $real_path/index.html". - " --start_from_command $start_from_command ". + $fragment_options. + " --output $real_path/index$page_id.html". " --filter '$filter'"; system($l3_frontend) == 0 or error("Файл журнала найден, но возникла ошибка при его обработке:
$!"); @@ -96,7 +110,7 @@ { local $/; - open(HTML, "<:utf8", "$real_path/index.html"); + open(HTML, "<:utf8", "$real_path/index$page_id.html"); my $html = ; # Добавим в начало документа навигационную строку diff -r 40d843395547 -r 822b36252d7f l3-frontend --- a/l3-frontend Fri Mar 06 13:34:59 2009 +0600 +++ b/l3-frontend Tue Jun 23 01:15:02 2009 +0300 @@ -354,7 +354,12 @@ $dir=$_[0]; for $i (glob("$dir/*.png")) { $i =~ s@.*/(([0-9-]+)_([0-9]+).*)@$1@; - $Uploads{$2}{$3}=$i; + if (defined($Uploads{$2}{$3})) { + $Uploads{$2}{$3} .= " ".$i; + } + else { + $Uploads{$2}{$3}=$i; + } } } @@ -633,7 +638,7 @@ my $cl=$Command_Lines[$Command_Lines_Index[$current_command++]]; next unless $cl; - my $next_cl=$Command_Lines[$Command_Lines_Index[$current_command+1]]; + my $next_cl=$Command_Lines[$Command_Lines_Index[$current_command]]; next if $current_command < $Config{"start_from_command"}; last if $current_command > $Config{"start_from_command"} + $Config{"commands_to_show_at_a_go"}; @@ -834,23 +839,28 @@ if ( $Config{"show_diffs"} =~ /^y/i && $cl->{"diff"}); # SHOT - $this_day_result .= join(".", key(%Uploads)); - $this_day_result .= "PRIVET"; + #$this_day_result .= join(".", keys(%Uploads)); + #$this_day_result .= "PRIVET"; for $t (sort { $a <=> $b } keys %{ $Uploads{$cl->{"local_session_id"}} }) { - # if ($t > $cl->{"time"} && $t < $next_cl->{"time"}) { - $this_day_result .= "screenshot id ".$cl->{"screenshot"}
-                ."" + if (($t >= $cl->{"time"} and $t < $next_cl->{"time"}) or ($t >= $cl->{"time"} and not defined($next_cl))) { + my @shots=split(/\s+/, $Uploads{$cl->{"local_session_id"}}{$t}); + for my $shot (@shots) { + $this_day_result .= "screenshot id ".$shot
+                        ."
" + } + } } - $this_day_result .= "screenshot id ".$cl->{"screenshot"}
-                ."" - if ( $Config{"show_screenshots"} =~ /^y/i && $cl->{"screenshot"}); +# Временно заблокировано +# $this_day_result .= "screenshot id ".$cl->{"screenshot"}
+#                ."" +# if ( $Config{"show_screenshots"} =~ /^y/i && $cl->{"screenshot"}); #NOTES if ( $Config{"show_notes"} =~ /^y/i && $cl->{"note"}) { diff -r 40d843395547 -r 822b36252d7f l3pre.php --- a/l3pre.php Fri Mar 06 13:34:59 2009 +0600 +++ b/l3pre.php Tue Jun 23 01:15:02 2009 +0300 @@ -1,14 +1,35 @@ setHook( "lilalo", "renderLiLaLoPRE" ); + global $wgOut; + $wgOut->addHTML(''); } +$markerList = array(); + function renderLiLaLoPRE( $input ) { + global $markerList; preg_match('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', $input, $matches); $session_id=$matches[1]; + if ($session_id) { preg_match('/([0-9]*)-([0-9]*)/', $session_id, $matches); $session_start_time = intval($matches[2]); $hour=intval(date('G', $session_start_time)); @@ -21,7 +42,36 @@ .'">$5\'', $input); # .strval($session_start_time+3600*(intval($2)-$hour)+60*(intval($3)-$min)+(intval($4)-$sec)) - return "
$hour:$min:$sec $input
"; + $time_prefix="$hour:$min:$sec "; + } + else + { + $tip_text='
-nshow numerical addresses instead of trying to determine symbolic host names.
This is useful if you are trying to determine why the route to your nameserver has vanished.
'; + #$tip_text='1'; + $tip=" onmouseover=\"Tip('".$tip_text."')\" onmouseout=\"UnTip()\""; + $input = preg_replace('/(%#.*)/', '$1', $input); + } + $output = "
$time_prefix$input
"; + $markercount = count($markerList); + $marker = "xx-lilalo-marker".$markercount."-xx"; + $markerList[$markercount] = $output; + return $marker; + } +function wfLiLaLoParserAfterTidy(&$parser, &$text) { + // find markers in $text + // replace markers with actual output + global $markerList; + $keys = array(); + $marker_count = count($markerList); + + for ($i = 0; $i < $marker_count; $i++) { + $keys[$i] = 'xx-lilalo-marker' . $i . '-xx'; + } + + $text = str_replace($keys, $markerList, $text); +#$text = $marker_count; + return true; +} ?>