[LON-CAPA-cvs] cvs: loncom / loncnew
foxr
lon-capa-cvs@mail.lon-capa.org
Tue, 13 Jan 2004 09:57:18 -0000
foxr Tue Jan 13 04:57:18 2004 EDT
Modified files:
/loncom loncnew
Log:
Added capability for transaction logging. To toggle between 'normal' operation
and transaction logging and back, send USR2 at a specific lonc daemon.
Transactions are logged in the /home/httpd/perl/lonc.log file with success
status, as normal log messages. Two types of messages are generated:
Transaction: yadayada
Reply from lond: yadayada
Transaction is a request issued to lonc from a local client.
Reply from lond: is a transaction reply.
Note that no effort is made, at this time, to match up transactions and replies or even to tag them, so in a heavily used access server, this logging will be confusing as multiple simultaneous transactions and replies fly back and forth.
For later work, it may be useful to assign transactions a monotonically incrementing serial number and add that serial number to log messages that are relevant
to that transaction (sort of like the mail id you see in an smtp log file).
Index: loncom/loncnew
diff -u loncom/loncnew:1.38 loncom/loncnew:1.39
--- loncom/loncnew:1.38 Mon Jan 5 04:29:36 2004
+++ loncom/loncnew Tue Jan 13 04:57:18 2004
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# lonc maintains the connections to remote computers
#
-# $Id: loncnew,v 1.38 2004/01/05 09:29:36 foxr Exp $
+# $Id: loncnew,v 1.39 2004/01/13 09:57:18 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -89,6 +89,8 @@
my $NextDebugLevel= 2; # So Sigint can toggle this.
my $IdleTimeout= 3600; # Wait an hour before pruning connections.
+my $LogTransactions = 0; # When True, all transactions/replies get logged.
+
#
# The variables below are only used by the child processes.
#
@@ -513,6 +515,9 @@
if (!$Transaction->isDeferred()) { # Normal transaction
my $data = $Socket->GetReply(); # Data to send.
+ if($LogTransactions) {
+ Log("SUCCESS", "Reply from lond: '$data'");
+ }
StartClientReply($Transaction, $data);
} else { # Delete deferred transaction file.
Log("SUCCESS", "A delayed transaction was completed");
@@ -1217,6 +1222,9 @@
exit;
}
Debug(8, "Complete transaction received: ".$data);
+ if($LogTransactions) {
+ Log("SUCCESS", "Transaction: '$data'"); # Transaction has \n.
+ }
my $Transaction = LondTransaction->new($data);
$Transaction->SetClient($socket);
QueueTransaction($Transaction);
@@ -1325,6 +1333,24 @@
fd => $socket);
}
+#
+# Toggle transaction logging.
+# Implicit inputs:
+# LogTransactions
+# Implicit Outputs:
+# LogTransactions
+sub ToggleTransactionLogging {
+ print STDERR "Toggle transaction logging...\n";
+ if(!$LogTransactions) {
+ $LogTransactions = 1;
+ } else {
+ $LogTransactions = 0;
+ }
+
+
+ Log("SUCCESS", "Toggled transaction logging: $LogTransactions \n");
+}
+
=pod
=head2 ChildStatus
@@ -1422,6 +1448,8 @@
Event->signal(signal => "USR1",
cb => \&ChildStatus,
data => "USR1");
+ Event->signal(signal => "USR2",
+ cb => \&ToggleTransactionLogging);
Event->signal(signal => "INT",
cb => \&ToggleDebug,
data => "INT");