From 21598bc69144d139305ee49c6241d1ed411a2b44 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 4 Dec 2007 00:07:21 +0000 Subject: Make ExtendedLogging use the logging framework so that we can view the logs on the console along with other debug output. --- lib/server/makeprotocol.pl.in | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/server/makeprotocol.pl.in b/lib/server/makeprotocol.pl.in index f4561168..269ff3f5 100755 --- a/lib/server/makeprotocol.pl.in +++ b/lib/server/makeprotocol.pl.in @@ -503,11 +503,11 @@ __E if($implement_syslog) { - my ($format,$args) = make_log_strings($cmd); + my ($log) = make_log_strings_framework($cmd); print CPP <<__E; void ${class}LogSysLog(const char *Action) const { - ::syslog(LOG_INFO,"%s $format",Action$args); + BOX_TRACE($log); } __E } @@ -1004,4 +1004,45 @@ sub make_log_strings return ($cmd.'('.join(',',@str).')', join(',','',@arg)); } +sub make_log_strings_framework +{ + my ($cmd) = @_; + + my @args; + + for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) + { + my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); + + if(exists $log_display_types{$ty}) + { + # need to translate it + my ($format,$arg) = @{$log_display_types{$ty}}; + $arg =~ s/VAR/m$nm/g; + + if ($format =~ m'x$') + { + $arg = "std::hex << std::showbase " . + "<< $arg << std::dec"; + } + + push @args, $arg; + } + else + { + # is opaque + push @args, '"OPAQUE"'; + } + } + + my $log_cmd = "Action << \" $cmd(\" "; + foreach my $arg (@args) + { + $arg = "<< $arg "; + } + $log_cmd .= join('<< "," ',@args); + $log_cmd .= '<< ")"'; + return $log_cmd; +} + -- cgit v1.2.3