Re: Online custom logging
Posted in 2003
Topics: Installation, Setup & Upgrades, Logging & Checkpoints, Versions, Editions & End-of-Life
Indeed, assuming perl is installed:
===
#!/usr/local/bin/perl
# boll - beautify on-line log output
# Usage: boll [-d] <online-log-file>
# Options:
# -d output in pipe-delimited format
$sccs_id = "boll.pl 1.1 richardt 03/06/04 15:37:58";
$s = " ";
%m = (
'Jan','01',
'Feb','02',
'Mar','03',
'Apr','04',
'May','05',
'Jun','06',
'Jul','07',
'Aug','08',
'Sep','09',
'Oct','10',
'Nov','11',
'Dec','12'
);
if($ARGV[0] eq "-d")
{
shift;
$s = "|";
}
while(<>)
{
$dt=sprintf("%d-%s-%.2d", $3, $m{$1}, $2)
if /^\\w{3} (\\w{3}) (\\d+) [0-9:]+ (\\d+)$/;
next unless $dt && /^[0-9]/;
s/ /$s/;
printf "$dt $_";
}
====
Share and enjoy,
RET
PS - The original request was a couple of weeks ago. It can take
awhile to catch up with the list after a holiday :-/ Better latex than
never...
On Wednesday, May 14, 2003, at 07:29 AM, Richard Kofler wrote:
> Michael Pisula wrote:
>>
>> In IDS 9.30, is it possible to add the 'Date' of the event to the
>> timestamp. So a typical log is now:
>>
>> 09:51:47 Maximum server connections 70
>> 10:01:49 Fuzzy Checkpoint Completed: duration was 2 seconds, 1487>> buffers not flushed.
>> 10:01:49 Checkpoint loguniq 16932, logpos 0x2561740>>
>> It'd be great to have it be something like:
>>
>> 05/10/2003 09:51:47 Maximum server connections 70
>> 05/10/2003 10:01:49 Fuzzy Checkpoint Completed: duration was 2
>> seconds, 1487 buffers not flushed.
>> 05/10/2003 10:01:49 Checkpoint loguniq 16932, logpos 0x2561740
>>
>> or similar.
>>
>> Thank you,
>> Mike
>
> if you are on Windows you always can install the cygwin toolset
> or a similar toolset (GNU tools for DOS)
> and you will have the benefit of awk.
>
> Or, even better, install perl (www.cpan.org).
> This will enable you to do any kind of log filtering and
> pretty printing - and some more ...
>
> dic_k
>
Richard Thomas <ret@mac.com> writes: Very nice, except that it did not quite work at first: When the day of month is only one digit it has _two_ spaces in front. Like this: Wed Jun 4 04:00:55 2003 ^^ So, I changed the regexp, see embedded comment. > Indeed, assuming perl is installed: > > === > #!/usr/local/bin/perl > > # boll - beautify on-line log output > # Usage: boll [-d] <online-log-file> > # Options: > # -d output in pipe-delimited format > > $sccs_id = "boll.pl 1.1 richardt 03/06/04 15:37:58"; > > $s = " "; > %m = ( > 'Jan','01', > 'Feb','02', > 'Mar','03', > 'Apr','04', > 'May','05', > 'Jun','06', > 'Jul','07', > 'Aug','08', > 'Sep','09', > 'Oct','10', > 'Nov','11', > 'Dec','12' > ); > > if($ARGV[0] eq "-d") > { > shift; > $s = "|"; > } > > while(<>) > { > $dt=sprintf("%d-%s-%.2d", $3, $m{$1}, $2) > if /^\\w{3} (\\w{3}) (\\d+) [0-9:]+ (\\d+)$/; change this line to if /^\\w{3} (\\w{3}) +(\\d+) [0-9:]+ (\\d+)$/; > next unless $dt && /^[0-9]/; > s/ /$s/; > printf "$dt $_"; > } > > ==== > Share and enjoy, > > RET > > PS - The original request was a couple of weeks ago. It can take > awhile to catch up with the list after a holiday :-/ Better latex than > never... > -- 'yvind Gjerstad Systems dept Tollpost-Globe AS N-6301 'ndalsnes/Norway E-mail: ogj@tollpost.no Phone: +47 7122 6663 Fax: +47 7122 6694
Also, the question on how to handle things like this remains:
14:02:38 DDR Log Snooping - Snooping started in log 9209
14:02:38 CDR grouperEvalThread: Could not apply undo properly. SKIPPING TRANSACTION. TX Begin Time: Wed Jun 4 09:14:16 2003
TX Restart Log Id: 9209
TX Restart Log Position: 0x427d6a4
TX Commit Time: Wed Jun 4 09:14:16 2003
TX End Log Id: 9209
TX End Log Position: 0x428a110
14:02:39 CDR: Re-connected to server, id 20, name <grp_dbhist>
This comes out as:
2003-06-04 14:02:38 DDR Log Snooping - Snooping started in log 9209
2003-06-04 14:02:38 CDR grouperEvalThread: Could not apply undo properly. SKIPPING TRANSACTION.
2003-06-04 14:02:39 CDR: Re-connected to server, id 20, name <grp_dbhist>
So, some information is lost. Maybe you should reproduce the timestamp from
the previuse line if the timestamp is not there. Something like:
(only the while loop):
while(<>)
{
$dt=sprintf("%d-%s-%.2d", $3, $m{$1}, $2)
if /^\\w{3} (\\w{3}) +(\\d+) [0-9:]+ (\\d+)$/;
next if m/^\\s*$/;
if (/^(^\\d\\d:\\d\\d:\\d\\d)/) {
$tm = $1;
} else {
$_ = "$tm " . $_;
}
next unless $dt && $tm;
s/ /$s/;
printf "$dt $_";
}
--
'yvind Gjerstad Systems dept Tollpost-Globe AS N-6301 'ndalsnes/Norway
E-mail: ogj@tollpost.no Phone: +47 7122 6663 Fax: +47 7122 6694