Index: trunk/extensions/Translate/scripts/logfilter.php |
— | — | @@ -0,0 +1,44 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A script to forward error log messages with some rate limiting. |
| 5 | + * |
| 6 | + * @author Niklas Laxstrom |
| 7 | + * |
| 8 | + * @copyright Copyright © 2010, Niklas Laxström |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + * @file |
| 11 | + */ |
| 12 | + |
| 13 | +$file = @$_SERVER['argv'][1]; |
| 14 | +if ( !is_readable( $file ) ) { |
| 15 | + exit( "OMG\n" ); |
| 16 | +} |
| 17 | + |
| 18 | +$handle = fopen( $file, "rt" ); |
| 19 | +fseek( $handle, 0, SEEK_END ); |
| 20 | +while ( true ) { |
| 21 | + $count = 0; |
| 22 | + $line = false; |
| 23 | + while ( !feof( $handle ) ) { |
| 24 | + $count++; |
| 25 | + $input = fgets( $handle ); |
| 26 | + if ( $input !== false ) $line = $input; |
| 27 | + } |
| 28 | + |
| 29 | + // I don't know why this is needed |
| 30 | + fseek( $handle, 0, SEEK_END ); |
| 31 | + |
| 32 | + if ( $line !== false ) { |
| 33 | + $prefix = ''; |
| 34 | + if ( $count > 2 ) { |
| 35 | + $count -= 2; |
| 36 | + $prefix = "($count lines skipped) "; |
| 37 | + } |
| 38 | + if ( mb_strlen( $line ) > 400 ) { |
| 39 | + $line = mb_substr( $line, 0, 400 ) . '...'; |
| 40 | + } |
| 41 | + echo trim( $prefix.$line ) . "\n"; |
| 42 | + } |
| 43 | + |
| 44 | + sleep( 10 ); |
| 45 | +} |
Property changes on: trunk/extensions/Translate/scripts/logfilter.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 46 | + native |