Commit 02fb23d6 authored by sikeda's avatar sikeda
Browse files

[-dev] Now functions of Log package won't be exported

so that qualified names should be used:
Log::fatal_err(), Log::do_openlog(), Log::do_log().


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@10135 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 1e58a0fb
......@@ -44,10 +44,10 @@ unless (Conf::load($config_file)) {
# setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
do_log('info', "Logs seems OK, log level set using options : $main::options{'log_level'}");
Log::do_log('info', "Logs seems OK, log level set using options : $main::options{'log_level'}");
}else{
&Log::set_log_level($Conf{'log_level'});
do_log('info', "Logs seems OK, default log level $Conf{'log_level'}");
Log::do_log('info', "Logs seems OK, default log level $Conf{'log_level'}");
}
printf "Ok, now check logs \n";
......
......@@ -447,7 +447,7 @@ sub store {
$messagekey, $msg_id, $msg, $dkim->{d}, $dkim->{i},
$dkim->{selector}, $dkim->{private_key}
)) {
do_log('err',
Log::do_log('err',
'Unable to add message in bulkspool_table "%s"',
sprintf($statementtrace,
SDM::quote($messagekey), SDM::quote($msg_id),
......
......@@ -4319,7 +4319,7 @@ sub send_msg {
my $subject = $message->{'msg'}->head->get('Subject');
my $sender = $message->{'msg'}->head->get('From');
unless ($self->send_file('x509-user-cert-missing', $user->{'email'}, $robot, {'mail' => {'subject' => $subject, 'sender' => $sender}, 'auto_submitted' => 'auto-generated'})) {
&do_log('notice',"Unable to send template 'x509-user-cert-missing' to $user->{'email'}");
Log::do_log('notice',"Unable to send template 'x509-user-cert-missing' to $user->{'email'}");
}
}else{
if ($user->{'bounce_score'}) {
......@@ -4540,7 +4540,7 @@ sub send_msg {
'dkim_parameters'=>$dkim_parameters,
'tag_as_last' => $tags_to_use->{'tag_noverp'});
unless (defined $result) {
&do_log('err',"List::send_msg, could not send message to distribute from $from (verp desabled)");
Log::do_log('err',"List::send_msg, could not send message to distribute from $from (verp desabled)");
return undef;
}
$tags_to_use->{'tag_noverp'} = 0 if ($result > 0);
......@@ -4575,7 +4575,7 @@ sub send_msg {
'dkim_parameters'=>$dkim_parameters,
'tag_as_last' => $tags_to_use->{'tag_verp'});
unless (defined $result) {
&do_log('err',"List::send_msg, could not send message to distribute from $from (verp enabled)");
Log::do_log('err',"List::send_msg, could not send message to distribute from $from (verp enabled)");
return undef;
}
$tags_to_use->{'tag_verp'} = 0 if ($result > 0);
......@@ -12967,7 +12967,7 @@ sub purge {
## Clean list table if needed
if ($Conf::Conf{'db_list_cache'} eq 'on') {
unless (&SDM::do_query('DELETE FROM list_table WHERE name_list = %s AND robot_list = %s', &SDM::quote($self->{'name'}), &SDM::quote($self->{'domain'}))) {
&do_log('err', 'Cannot remove list %s (robot %s) from table', $self->{'name'}, $self->{'domain'});
Log::do_log('err', 'Cannot remove list %s (robot %s) from table', $self->{'name'}, $self->{'domain'});
}
}
......
......@@ -398,11 +398,11 @@ sub _get_sender_email {
last if defined $sender;
}
unless (defined $sender) {
do_log('err', 'No valid sender address');
Log::do_log('err', 'No valid sender address');
return undef;
}
unless (tools::valid_email($sender)) {
do_log('err', 'Invalid sender address "%s"', $sender);
Log::do_log('err', 'Invalid sender address "%s"', $sender);
return undef;
}
......
......@@ -156,14 +156,14 @@ sub establish_connection {
## ODBC just needs a db_name, db_user
foreach my $db_param ('db_user','db_passwd') {
unless ($self->{$db_param}) {
do_log('info','Missing parameter %s for DBI connection', $db_param);
Log::do_log('info','Missing parameter %s for DBI connection', $db_param);
return undef;
}
}
} else {
foreach my $db_param ('db_host','db_user','db_passwd') {
unless ($self->{$db_param}) {
do_log('info','Missing parameter %s for DBI connection', $db_param);
Log::do_log('info','Missing parameter %s for DBI connection', $db_param);
return undef;
}
}
......@@ -279,7 +279,7 @@ sub establish_connection {
unless (defined $self->{'dbh'}->do("SET NAMES 'utf8mb4'") or
defined $self->{'dbh'}->do("SET NAMES 'utf8'")) {
do_log('err', 'Cannot set client-side character set: %s',
Log::do_log('err', 'Cannot set client-side character set: %s',
$self->{'dbh'}->errstr);
}
}
......@@ -311,7 +311,7 @@ sub establish_connection {
$db_connections{$self->{'connect_string'}}{'dbh'} = $self->{'dbh'};
$db_connections{$self->{'connect_string'}}{'db_user'} = $self->{'db_user'};
do_log('debug2','Connected to Database %s',$self->{'db_name'});
Log::do_log('debug2','Connected to Database %s',$self->{'db_name'});
## We set Long preload length to two times global max message size
## (because of base64 encoding) instead of defaulting to 80 on Oracle
......@@ -328,7 +328,7 @@ sub establish_connection {
$self->{'dbh'}->{LongReadLen} = ($Conf::Conf{'max_size'} || 102400) * 2;
$self->{'dbh'}->{LongTruncOk} = 0;
}
do_log('debug3',
Log::do_log('debug3',
'Database driver seetings for this session: LongReadLen= %d, LongTruncOk = %d, RaiseError= %d',
$self->{'dbh'}->{LongReadLen}, $self->{'dbh'}->{LongTruncOk},
$self->{'dbh'}->{RaiseError});
......
......@@ -206,7 +206,7 @@ sub create_list_old{
}
if ($param->{'listname'} eq &Conf::get_robot_conf($robot,'email')) {
&do_log('err','admin::create_list : incorrect listname %s matches one of service aliases', $param->{'listname'});
Log::do_log('err','admin::create_list : incorrect listname %s matches one of service aliases', $param->{'listname'});
return undef;
}
......@@ -285,7 +285,7 @@ sub create_list_old{
return undef;
}
unless (open CONFIG, '>', "$list_dir/config") {
&do_log('err','Impossible to create %s/config : %s', $list_dir, $!);
Log::do_log('err','Impossible to create %s/config : %s', $list_dir, $!);
$lock->unlock();
return undef;
}
......@@ -417,7 +417,7 @@ sub create_list{
}
}
if ($param->{'listname'} eq &Conf::get_robot_conf($robot,'email')) {
&do_log('err','admin::create_list : incorrect listname %s matches one of service aliases', $param->{'listname'});
Log::do_log('err','admin::create_list : incorrect listname %s matches one of service aliases', $param->{'listname'});
return undef;
}
......@@ -494,7 +494,7 @@ sub create_list{
## Creation of the config file
unless (open CONFIG, '>', "$list_dir/config") {
&do_log('err','Impossible to create %s/config : %s', $list_dir, $!);
Log::do_log('err','Impossible to create %s/config : %s', $list_dir, $!);
$lock->unlock();
return undef;
}
......@@ -639,7 +639,7 @@ sub update_list{
## Creation of the config file
unless (open CONFIG, '>', "$list->{'dir'}/config") {
&do_log('err','Impossible to create %s/config : %s', $list->{'dir'}, $!);
Log::do_log('err','Impossible to create %s/config : %s', $list->{'dir'}, $!);
$lock->unlock();
return undef;
}
......@@ -678,11 +678,11 @@ sub update_list{
my $file_content;
my $tt_result = &tt2::parse_tt2($param, $file.".tt2", \$file_content, [$family->{'dir'}]);
unless (defined $tt_result) {
&do_log('err', 'admin::create_list : tt2 error. List %s from family %s@%s, file %s',
Log::do_log('err', 'admin::create_list : tt2 error. List %s from family %s@%s, file %s',
$param->{'listname'}, $family->{'name'},$robot,$file);
}
unless (open FILE, '>', "$list->{'dir'}/$file") {
&do_log('err','Impossible to create %s/%s : %s',$list->{'dir'},$file,$!);
Log::do_log('err','Impossible to create %s/%s : %s',$list->{'dir'},$file,$!);
}
print FILE $file_content;
close FILE;
......
......@@ -724,7 +724,7 @@ sub sendto {
foreach my $unique_rcpt (@{$rcpt}) {
my $email = lc(@{$unique_rcpt}[0]);
if (($email !~ /@/) || ($#{@$unique_rcpt} != 0)) {
do_log('err',"incorrect call for encrypt with incorrect number of recipient");
Log::do_log('err',"incorrect call for encrypt with incorrect number of recipient");
# internal check, if encryption is on packet should be unique and shoud contain only one rcpt
return undef;
}
......
......@@ -1344,7 +1344,7 @@ sub smime_decrypt {
my $list = shift ; ## the recipient of the msg
my $from = $msg->head->get('from');
&do_log('debug2', 'tools::smime_decrypt message msg from %s,%s', $from, $list->{'name'});
Log::do_log('debug2', 'tools::smime_decrypt message msg from %s,%s', $from, $list->{'name'});
## an empty "list" parameter means mail to sympa@, listmaster@...
my $dir = $list->{'dir'};
......@@ -2297,7 +2297,7 @@ sub get_filename {
}
my @result;
foreach my $f (@try) {
&do_log('debug3','get_filename : name: %s ; dir %s', $name, $f );
Log::do_log('debug3','get_filename : name: %s ; dir %s', $name, $f );
if (-r $f) {
if ($options->{'order'} eq 'all') {
push @result, $f;
......@@ -2512,7 +2512,7 @@ sub remove_pid {
## Then the pidfile contains a list of space-separated PIDs on a single line
if($options->{'multiple_process'}) {
unless(open(PFILE, $pidfile)) {
# fatal_err('Could not open %s, exiting', $pidfile);
# Log::fatal_err('Could not open %s, exiting', $pidfile);
&Log::do_log('err','Could not open %s to remove pid %s', $pidfile, $pid);
return undef;
}
......@@ -2586,7 +2586,7 @@ sub write_pid {
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
)) {
&fatal_err('Unable to set rights on %s. Exiting.', $Conf::Conf{'db_name'});
Log::fatal_err('Unable to set rights on %s. Exiting.', $Conf::Conf{'db_name'});
}
my @pids;
......@@ -2594,11 +2594,11 @@ sub write_pid {
# Lock pid file
my $lock = new Lock ($pidfile);
unless (defined $lock) {
&fatal_err('Lock could not be created. Exiting.');
Log::fatal_err('Lock could not be created. Exiting.');
}
$lock->set_timeout(5);
unless ($lock->lock('write')) {
&fatal_err('Unable to lock %s file in write mode. Exiting.',$pidfile);
Log::fatal_err('Unable to lock %s file in write mode. Exiting.',$pidfile);
}
## If pidfile exists, read the PIDs
if(-f $pidfile) {
......@@ -2615,7 +2615,7 @@ sub write_pid {
unless(open(PIDFILE, '> '.$pidfile)) {
## Unlock pid file
$lock->unlock();
&fatal_err('Could not open %s, exiting: %s', $pidfile,$!);
Log::fatal_err('Could not open %s, exiting: %s', $pidfile,$!);
}
## Print other pids + this one
push(@pids, $pid);
......@@ -2626,7 +2626,7 @@ sub write_pid {
unless(open(PIDFILE, '+>> '.$pidfile)) {
## Unlock pid file
$lock->unlock();
&fatal_err('Could not open %s, exiting: %s', $pidfile);
Log::fatal_err('Could not open %s, exiting: %s', $pidfile);
}
## The previous process died suddenly, without pidfile cleanup
## Send a notice to listmaster with STDERR of the previous process
......
......@@ -42,18 +42,18 @@ my $robot_id = $options{'domain'};
# Load configuration
my $sympa_conf_file = Sympa::Constants::CONFIG;
unless ( Conf::load( $sympa_conf_file, 'no_db' ) ) { # skip db config
do_log( 'err', 'The configuration file %s contains error',
Log::do_log( 'err', 'The configuration file %s contains error',
$sympa_conf_file );
exit 1;
}
do_openlog( $Conf{'syslog'}, $Conf{'log_socket_type'}, 'sympa_newaliases' );
Log::do_openlog( $Conf{'syslog'}, $Conf{'log_socket_type'}, 'sympa_newaliases' );
Log::set_log_level( $Conf{'log_level'} );
my ( $aliases_file, $aliases_program, $aliases_db_type );
if ($robot_id) {
unless ( Conf::valid_robot($robot_id) ) {
do_log( 'err', 'robot %s does not exist', $robot_id );
Log::do_log( 'err', 'robot %s does not exist', $robot_id );
exit 1;
}
$aliases_file = Conf::get_robot_conf( $robot_id, 'sendmail_aliases' );
......@@ -67,29 +67,29 @@ if ($robot_id) {
if ( $aliases_file eq 'none' ) {
exit 0; # do nothing
} elsif ( !-e $aliases_file ) {
do_log( 'err', 'The aliases file %s does not exist', $aliases_file );
Log::do_log( 'err', 'The aliases file %s does not exist', $aliases_file );
exit 1;
}
unless ( $aliases_db_type =~ /\A\w+\z/ ) {
do_log( 'err', 'Invalid aliases_db_type "%s"', $aliases_db_type );
Log::do_log( 'err', 'Invalid aliases_db_type "%s"', $aliases_db_type );
exit 1;
}
if ( $aliases_program =~ m{\A/} ) {
do_log( 'debug2', 'executing "%s %s"', $aliases_program, $aliases_file );
Log::do_log( 'debug2', 'executing "%s %s"', $aliases_program, $aliases_file );
exec $aliases_program, $aliases_file;
} elsif ( $aliases_program eq 'makemap' ) {
do_log( 'debug2', 'executing "%s %s %s < %s"',
Log::do_log( 'debug2', 'executing "%s %s %s < %s"',
q{--MAKEMAP--}, $aliases_db_type, $aliases_file, $aliases_file );
unless ( open STDIN, '<', $aliases_file ) {
do_log( 'err', 'Canot open $s', $aliases_file );
Log::do_log( 'err', 'Canot open $s', $aliases_file );
exit 1;
}
exec q{--MAKEMAP--}, $aliases_db_type, $aliases_file;
} elsif ( $aliases_program eq 'newaliases' ) {
do_log( 'debug2', 'executing "%s"',
Log::do_log( 'debug2', 'executing "%s"',
q{--NEWALIASES-- --NEWALIASES_ARG--} );
# Some newaliases utilities e.g. with Postfix cannot take arguments.
......@@ -101,22 +101,22 @@ if ( $aliases_program =~ m{\A/} ) {
exec q{--NEWALIASES--};
}
} elsif ( $aliases_program eq 'postalias' ) {
do_log( 'debug2', 'executing "%s %s:%s"',
Log::do_log( 'debug2', 'executing "%s %s:%s"',
q{--POSTALIAS--}, $aliases_db_type, $aliases_file );
exec q{--POSTALIAS--}, "$aliases_db_type:$aliases_file";
} elsif ( $aliases_program eq 'postmap' ) {
do_log( 'debug2', 'executing "%s %s:%s"',
Log::do_log( 'debug2', 'executing "%s %s:%s"',
q{--POSTMAP--}, $aliases_db_type, $aliases_file );
exec q{--POSTMAP--}, "$aliases_db_type:$aliases_file";
} else {
do_log( 'err', 'Invalid aliases_program "%s"', $aliases_program );
Log::do_log( 'err', 'Invalid aliases_program "%s"', $aliases_program );
exit 1;
}
my $errno = $!;
do_log( 'Cannot execute aliases_program "%s": %s', $aliases_program, $errno );
Log::do_log( 'Cannot execute aliases_program "%s": %s', $aliases_program, $errno );
exit( $errno || 1 );
__END__
......
......@@ -5357,7 +5357,7 @@ sub do_family_signoff_request {
'ip' => $ip,
};
unless (&List::send_global_file('user_notification', $in{'email'}, $robot, $tt2_param)) {
&do_log('notice',"Unable to send template 'user_notification' to $in{'email'}");
Log::do_log('notice',"Unable to send template 'user_notification' to $in{'email'}");
return undef;
}
$param->{'signing_off_email'} = $in {'email'};
......@@ -7164,7 +7164,7 @@ sub do_skinsedit {
 
## messages
foreach my $id (split (/,/, $in{'id'})) { # QUIET DISTRIBUTE
&do_log('notice', 'Moderator approves message: %s %s', $list->{'name'},$id);
Log::do_log('notice', 'Moderator approves message: %s %s', $list->{'name'},$id);
my $mail_command = sprintf ("QUIET DISTRIBUTE %s %s\n",$list->{'name'},$id);
$data->{'body'} .= $mail_command;
 
......
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