Hi Heikki,

By the way, sorry, one more feature wish:

You know, MessageLogFILE unconditionally logs *every* recv/sent RADIUS packet, this fills the disks very quickly and gets unhandy for further debug processing.

What do you think about a LogSkipHook in MessageLogFILE?
I implemented it now and 'it works well for me'(TM),

See the attached patch, this would be very helpful for debugging sporadically occurring errors.

I would be glad if you could accept this feature request or patch.

Best Regards
   Charly

--
Karl Gaissmaier
Universität Ulm
kiz, Kommunikations und Informationszentrum
89069 Ulm
Tel.: 49(0)731/50-22499
Fax : 49(0)731/50-12-22499

diff --git a/Radius/MessageLogFILE.pm b/Radius/MessageLogFILE.pm
index a0c7e0b..3f2d4c6 100644
--- a/Radius/MessageLogFILE.pm
+++ b/Radius/MessageLogFILE.pm
@@ -88,6 +88,17 @@ sub log_radius_msg
 {
     my ($self, $p, $from_ip, $from_port, $to_ip, $to_port, $data) = @_;
 
+    # skip this message by user request
+    if (defined $self->{LogSkipHook})
+    {
+       # help hook writers
+       my $from_ip = Radius::Util::inet_ntop($from_ip);
+       my $to_ip   = Radius::Util::inet_ntop($to_ip);
+
+       my ($skip) = $self->runHook('LogSkipHook', undef, $p, $from_ip, 
$from_port, $to_ip, $to_port);
+       return if $skip;
+    }
+
     my $format = $self->{Format};
     my $encoding = $self->{Encoding} || 
$Radius::MessageLogFILE::file_encoding_enum[0];
     my $filename = Radius::Util::format_special($self->{Filename}, $p, $self, 
'radius', $format, $encoding);
@@ -154,6 +165,17 @@ sub log_diameter_msg
 {
     my ($self, $m, $from_ip, $from_port, $to_ip, $to_port, $data) = @_;
 
+    # skip this message by user request
+    if (defined $self->{LogSkipHook})
+    {
+       # help hook writers
+       my $from_ip = Radius::Util::inet_ntop($from_ip);
+       my $to_ip   = Radius::Util::inet_ntop($to_ip);
+
+       my ($skip) = $self->runHook('LogSkipHook', undef, $m, $from_ip, 
$from_port, $to_ip, $to_port);
+       return if $skip;
+    }
+
     my $format = $self->{Format};
     my $encoding = $self->{Encoding} || 
$Radius::MessageLogFILE::file_encoding_enum[0];
     my $filename = Radius::Util::format_special($self->{Filename}, undef, 
$self, 'diameter', $format, $encoding);
diff --git a/Radius/MessageLogGeneric.pm b/Radius/MessageLogGeneric.pm
index 2bc7099..29286f3 100644
--- a/Radius/MessageLogGeneric.pm
+++ b/Radius/MessageLogGeneric.pm
@@ -16,6 +16,11 @@ use warnings;
 %Radius::MessageLogGeneric::ConfigKeywords =
 (
 
+ 'LogSkipHook' =>
+ ['hook',
+  'Specifies an optional Perl hook that will be run for each log message when 
defined. If it returns true the message is skipped and not logged. By default 
no Hook is defined and all messages are logged.',
+  1],
+
 );
 
 # RCS version number of this module
_______________________________________________
radiator mailing list
radiator@lists.open.com.au
http://lists.open.com.au/mailman/listinfo/radiator

Reply via email to