Commit df01a139 authored by sikeda's avatar sikeda
Browse files

[dev] Now all executables use Sympa::Log instead of Log.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12032 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 47d64e19
......@@ -12,14 +12,16 @@ use Sympa::Archive;
use Conf;
use Sympa::Constants;
use Sympa::DatabaseManager;
use Log;
use Sympa::Log;
use Sympa::Message;
use tools;
my $log = Sympa::Log->instance;
unless (Conf::load(Sympa::Constants::CONFIG)) {
die "Can't load Sympa configuration file";
}
Log::do_openlog(
$log->openlog(
$Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympa/mod2html'
......
......@@ -29,11 +29,13 @@ use warnings;
use Getopt::Long;
use Conf;
use Log;
use Sympa::Log;
my %options;
GetOptions(\%main::options, 'debug|d', 'log_level=s', 'config|f=s');
my $log = Sympa::Log->instance;
## Load configuration file
unless (Conf::load()) {
printf STDERR "Configuration file %s has errors.\n",
......@@ -42,7 +44,7 @@ unless (Conf::load()) {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog(
$log->openlog(
$Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympa/testlogs'
......@@ -50,12 +52,14 @@ Log::do_openlog(
# setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
Log::do_log('info',
"Logs seems OK, log level set using options : $main::options{'log_level'}"
$log->syslog(
'info',
'Logs seems OK, log level set using options: %s',
$main::options{'log_level'}
);
} else {
Log::set_log_level($Conf::Conf{'log_level'});
Log::do_log(
$log->{level} = $Conf::Conf{'log_level'};
$log->syslog(
'info',
'Logs seems OK, default log level %s',
$Conf::Conf{'log_level'}
......
......@@ -33,7 +33,7 @@ use Sympa::Constants;
use Sympa::DatabaseManager;
use Sympa::Language;
use Sympa::List;
use Log;
use Sympa::Log;
use Sympa::Tools::File;
my %options;
......@@ -47,6 +47,9 @@ $OUTPUT_AUTOFLUSH = 1;
# die unless ($s =~ /^y$/i);
#}
# FIXME: Is logging required?
my $log = Sympa::Log->instance;
## Load sympa config
unless (Conf::load()) {
die 'config_error';
......@@ -225,7 +228,7 @@ foreach my $tpl (@templates) {
mode => 0755,
)
) {
Log::do_log('err', 'Unable to set rights on %s',
$log->syslog('err', 'Unable to set rights on %s',
$Conf::Conf{'db_name'});
next;
}
......@@ -281,7 +284,7 @@ sub convert {
group => Sympa::Constants::GROUP
)
) {
Log::do_log('err', 'Unable to set rights on %s',
$log->syslog('err', 'Unable to set rights on %s',
$Conf::Conf{'db_name'});
return undef;
}
......
......@@ -34,7 +34,7 @@ use Pod::Usage;
use Sympa::Bulk;
use Conf;
use Sympa::Constants;
use Log;
use Sympa::Log;
use SDM;
my %options;
......@@ -48,6 +48,8 @@ if ($options{'help'}) {
exit 0;
}
my $log = Sympa::Log->instance;
# Load sympa.conf
unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) {
die sprintf
......@@ -90,7 +92,7 @@ sub process {
my ($row_mailer, $row_spool);
while ($row_mailer = $sth->fetchrow_hashref('NAME_lc')) {
if ($row_mailer->{lock_bulkmailer}) {
Log::do_log(
$log->syslog(
'info',
'Packet %s is locked. Skipping',
$row_mailer->{packetid_bulkmailer}
......@@ -127,7 +129,7 @@ sub process {
$row_spool = $sth2->fetchrow_hashref('NAME_lc');
$sth2->finish;
unless ($row_spool) {
Log::do_log('err', '%s: No messages found. Skipping',
$log->syslog('err', '%s: No messages found. Skipping',
$messagekey);
$sth2->finish;
next;
......@@ -199,7 +201,7 @@ sub process {
);
}
unless ($marshalled) {
Log::do_log(
$log->syslog(
'err',
'Packet %s of message %s could not be migrated into new spool',
$row_mailer->{packetid_bulkmailer},
......@@ -207,7 +209,7 @@ sub process {
);
next;
} else {
Log::do_log(
$log->syslog(
'notice',
'Packet %s of message %s was migrated into new spool as <%s>',
$row_mailer->{packetid_bulkmailer},
......
......@@ -35,7 +35,7 @@ use Sympa::Bulk;
use Sympa::Constants;
use Conf;
use Sympa::LockedFile;
use Log;
use Sympa::Log;
my %options;
unless (GetOptions(\%options, 'help|h', 'dry_run', 'version|v')) {
......@@ -48,6 +48,8 @@ if ($options{'help'}) {
exit 0;
}
my $log = Sympa::Log->instance;
unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) {
die sprintf 'Configuration file %s has errors.\n', Conf::get_sympa_conf();
}
......@@ -122,7 +124,8 @@ sub process {
## valid X-Sympa-Checksum prove the message comes from web interface with
## authenticated sender
unless ($message->{'checksum'} eq sympa_checksum($message->{'rcpt'})) {
Log::do_log('err', '%s: Incorrect X-Sympa-Checksum header', $message);
$log->syslog('err', '%s: Incorrect X-Sympa-Checksum header',
$message);
return undef;
}
......@@ -133,11 +136,11 @@ sub process {
tools::store_spool($spool_dir, $message, '%s@%s.%ld.%ld,%d',
[qw(localpart domainpart date pid RAND)])
unless $options{dry_run};
Log::do_log('info', '%s: Moved to msg spool', $message);
$log->syslog('info', '%s: Moved to msg spool', $message);
} else {
$bulk->store($message, [split /\s*,\s*/, $message->{rcpt}])
unless $options{dry_run};
Log::do_log('info', '%s: Moved to bulk spool', $message);
$log->syslog('info', '%s: Moved to bulk spool', $message);
}
return 1;
}
......
......@@ -32,7 +32,7 @@ use SOAP::Lite;
## Sympa API
use Conf;
use Sympa::List;
use Log;
use Sympa::Log;
use Sympa::SOAP;
use Sympa::SOAP::Transport;
......@@ -46,16 +46,15 @@ unless (Conf::load()) {
exit 1;
}
Log::set_log_level($Conf::Conf{'log_level'});
## Open log
my $log_facility = $Conf::Conf{'log_facility'} || $Conf::Conf{'syslog'};
Log::do_openlog(
$log_facility,
# Open log
my $log = Sympa::Log->instance;
$log->{level} = $Conf::Conf{'log_level'};
$log->openlog(
$Conf::Conf{'log_facility'} || $Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympasoap'
);
Log::do_log('info', 'SOAP server launched');
$log->syslog('info', 'SympaSOAP started');
## We set the real UID with the effective UID value
## It is usefull to allow execution of scripts like alias_manager
......@@ -64,7 +63,7 @@ $UID = $EUID; ## UID
$GID = $EGID; ## GID
unless (SDM::check_db_connect()) {
Log::do_log('err', 'SOAP server requires a RDBMS to run');
$log->syslog('err', 'SympaSOAP requires a RDBMS to run');
}
## The process should not fork for sending mail
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ use Sympa::Constants;
use Sympa::Crash; # Show traceback.
use Sympa::Language;
use Sympa::LockedFile;
use Log;
use Sympa::Log;
use tools;
use tt2;
......@@ -60,8 +60,9 @@ unless (defined Conf::load()) {
exit 1;
}
Log::set_log_level($Conf::Conf{'log_level'});
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
my $log = Sympa::Log->instance;
$log->{level} = $Conf::Conf{'log_level'};
$log->openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
my $tmp_alias_file = $Conf::Conf{'tmpdir'} . '/sympa_aliases.' . time;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment