ispman/bin ispman-agent,1.64,1.65

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31664/bin

Modified Files:
	ispman-agent 
Log Message:
changed logging from Log::FileSimple to Log::Agent

Index: ispman-agent
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman-agent,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- ispman-agent	5 Jun 2004 12:45:18 -0000	1.64
+++ ispman-agent	1 Aug 2004 21:15:51 -0000	1.65
@@ -19,7 +19,7 @@
 #use strict;
 use vars qw(
   $VERSION @ISA @EXPORT @EXPORT_OK $TEST
-  $name $hostname $hostnames $ispman  $domains $log
+  $name $hostname $hostnames $ispman  $domains
 );
 
 require Exporter;
@@ -33,7 +33,7 @@
 use Fcntl;
 use POSIX qw(tmpnam setsid);
 use Sys::Hostname;
-use Log::FileSimple;
+use Log::Agent;
 
 require "ispman.conf";
 
@@ -118,23 +118,23 @@
     #exit(1);
 }
 
-sub open_log {
-
-    # obsolete. Do nothing.
-
-}
-
 sub init_log {
-    $log = new Log::FileSimple(
-        name      => 'ispman-agent',
-        file      => $log_file,
-        mask      => -1,
-        autoflush => 1,
-    );
+    require Log::Agent::Driver::File;  # logging made to file
+    logconfig(-driver =>
+              Log::Agent::Driver::File->make(
+                                             -prefix      => $name,
+                                             -showpid     => $pid,
+                                             -channels    => {
+                                                 'error'  => "$log_file",
+                                                 'output' => "$log_file",
+                                                 'debug'  => "$log_file",
+                                             },
+                                             )
+              );
+
 }
 
 sub daemonize {
-    open_log;
     defined( my $pid = fork ) or die "Can't fork: $!";
     if ($pid) {
         open( "PID", ">$pid_file" );
@@ -147,13 +147,12 @@
     }
 }
 
-if ( $ARGV[0] eq "nodetach" ) {
-    open_log();
-}
-else {
+if ( $ARGV[0] ne "nodetach" ) {
     daemonize();
 }
 
+init_log;
+
 require ISPMan;
 import ISPMan;
 
@@ -223,7 +222,7 @@
           )
         {
             for $params ( keys %{ $processHash->{$domain}{$job} } ) {
-                log_message("Doing $job on $domain with parameters $params\n");
+                logsay("Doing $job on $domain with parameters $params");
                 $message = &{$job}( $domain, $params );
                 if ( $message == 1 ) {
                     $ispman->deleteProcesses(
@@ -239,7 +238,7 @@
     }
 
     if ($TEST) {
-        log_message( "Sleeping for ", 2 * $agentFrequency, " seconds" );
+        logsay( "Sleeping for ", 2 * $agentFrequency, " seconds" );
         sleep( 2 * $agentFrequency );
 
     }
@@ -251,7 +250,7 @@
 
 sub modifyDomain {
     my $domain = shift;
-    log_message("Modifying $domain\n");
+    logsay("Modifying $domain");
 
     my $module = "$install_dir/lib/dns.lib";
     do $module;
@@ -517,14 +516,6 @@
     return $error;
 }
 
-sub log_message {
-    $message = join " ", @_;
-    unless ( $log && ref($log) eq "Log::FileSimple" ) {
-        init_log();
-    }
-    $log->log( message => $message );
-}
-
 sub DESTROY {
     close("STDERR");
 }



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.