[Box Backup-commit] COMMIT r1971 - box/chris/general/lib/server
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sat, 8 Dec 2007 23:03:41 +0000 (UTC)
Author: chris
Date: 2007-12-08 23:03:41 +0000 (Sat, 08 Dec 2007)
New Revision: 1971
Modified:
box/chris/general/lib/server/makeprotocol.pl.in
Log:
Make ExtendedLogging use the logging framework so that we can view
the logs on the console along with other debug output. (merges [1937])
Modified: box/chris/general/lib/server/makeprotocol.pl.in
===================================================================
--- box/chris/general/lib/server/makeprotocol.pl.in 2007-12-08 23:02:06 UTC (rev 1970)
+++ box/chris/general/lib/server/makeprotocol.pl.in 2007-12-08 23:03:41 UTC (rev 1971)
@@ -503,11 +503,11 @@
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 @@
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;
+}
+
+