Commit 2e4d4a01 authored by sikeda's avatar sikeda
Browse files

[change] A few service names in system log and database logs were changed. ...

[change] A few service names in system log and database logs were changed.  Now they are taken from the name of each program:
- sympa_automatic.pl : "sympa_automatic" (formerley "sympa")
- sympa_msg.pl : "sympa_msg" (formerly "sympa")
Exception:
- sympa_soap_server.fcgi : "sympasoap" (formerly "soap")

ToDo: sympa_soap_server.fcgi would be renamed.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11978 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 728c32a6
......@@ -19,8 +19,11 @@ use tools;
unless (Conf::load(Sympa::Constants::CONFIG)) {
die "Can't load Sympa configuration file";
}
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa');
Log::do_openlog(
$Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympa/mod2html'
);
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless (Sympa::DatabaseManager::probe_db()) {
......
......@@ -42,8 +42,11 @@ unless (Conf::load()) {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa');
Log::do_openlog(
$Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympa/testlogs'
);
# setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
......
......@@ -50,7 +50,11 @@ 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, $Conf::Conf{'log_socket_type'}, 'soap');
Log::do_openlog(
$log_facility,
$Conf::Conf{'log_socket_type'},
service => 'sympasoap'
);
Log::do_log('info', 'SOAP server launched');
## We set the real UID with the effective UID value
......
......@@ -127,7 +127,7 @@ 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, $Conf::Conf{'log_socket_type'}, 'wwsympa');
Log::do_openlog($log_facility, $Conf::Conf{'log_socket_type'});
 
## Start plugins
if (eval "require Sympa::Plugin::Manager") {
......
......@@ -180,16 +180,25 @@ sub do_log {
}
sub do_openlog {
my $fac = shift;
my $facility = shift;
my $socket_type = shift;
my $service = shift || 'sympa';
my %options = @_;
($log_facility, $log_socket_type, $log_service) =
($fac, $socket_type, $service);
$log_service = $options{service} || _daemon_name() || 'sympa';
($log_facility, $log_socket_type) = ($facility, $socket_type);
return _do_connect();
}
# Old names: Log::set_daemon(), Sympa::Tools::Daemon::get_daemon_name().
sub _daemon_name {
my @path = split /\//, $PROGRAM_NAME;
my $service = $path[$#path];
$service =~ s/(\.[^\.]+)$//;
return $service;
}
# Old name: Log::do_connect().
sub _do_connect {
if ($log_socket_type =~ /^(unix|inet)$/i) {
Sys::Syslog::setlogsock(lc($log_socket_type));
......@@ -210,18 +219,6 @@ sub _do_connect {
return 1;
}
# Old names: Log::set_daemon(), Sympa::Tools::Daemon::get_daemon_name().
my $daemon_name;
sub _daemon_name {
return $daemon_name if $daemon_name;
my @path = split /\//, $PROGRAM_NAME;
$daemon_name = $path[$#path];
$daemon_name =~ s/(\.[^\.]+)$//;
return $daemon_name;
}
sub get_log_date {
my $sth;
my @dates;
......@@ -253,7 +250,7 @@ sub db_log {
my $error_type = $arg->{'error_type'};
my $user_email = $arg->{'user_email'};
my $client = $arg->{'client'};
my $daemon = _daemon_name();
my $daemon = $log_service || 'sympa';
my $date = time;
my $random = int(rand(1000000));
# my $id = $date * 1000000 + $random;
......@@ -272,16 +269,7 @@ sub db_log {
}
}
unless ($daemon
and $daemon =~
/^(task|archived|sympa|sympa_automatic|sympa_msg|wwsympa|bounced|sympa_soap)$/
) {
do_log('err', 'Internal_error: incorrect process value %s', $daemon);
return undef;
}
## Insert in log_table
# Insert in log_table
unless (
SDM::do_prepared_query(
q{INSERT INTO logs_table
......@@ -312,11 +300,11 @@ sub db_stat_log {
my $list = $arg->{'list'};
my $operation = $arg->{'operation'};
my $date = time; #epoch time : time since 1st january 1970
my $mail = $arg->{'mail'};
my $daemon = _daemon_name();
my $ip = $arg->{'client'};
my $robot = $arg->{'robot'};
my $date = time; #epoch time : time since 1st january 1970
my $mail = $arg->{'mail'};
my $daemon = $log_service || 'sympa';
my $ip = $arg->{'client'};
my $robot = $arg->{'robot'};
my $parameter = $arg->{'parameter'};
my $random = int(rand(1000000));
my $id = $date . $random;
......
......@@ -61,8 +61,7 @@ unless (defined Conf::load()) {
}
Log::set_log_level($Conf::Conf{'log_level'});
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'alias_manager');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
my $tmp_alias_file = $Conf::Conf{'tmpdir'} . '/sympa_aliases.' . time;
......
......@@ -135,7 +135,7 @@ if ($main::options{'log_level'}) {
}
my $log_facility = $Conf::Conf{'log_facility'} || $Conf::Conf{'syslog'};
Log::do_openlog($log_facility, $Conf::Conf{'log_socket_type'}, 'archived');
Log::do_openlog($log_facility, $Conf::Conf{'log_socket_type'});
## Set the User ID & Group ID for the process
$GID = $EGID = (getgrnam(Sympa::Constants::GROUP))[2];
......
......@@ -167,7 +167,7 @@ if ($main::options{'log_level'}) {
}
my $log_facility = $Conf::Conf{'log_facility'} || $Conf::Conf{'syslog'};
Log::do_openlog($log_facility, $Conf::Conf{'log_socket_type'}, 'bounced');
Log::do_openlog($log_facility, $Conf::Conf{'log_socket_type'});
## Set the User ID & Group ID for the process
$GID = $EGID = (getgrnam(Sympa::Constants::GROUP))[2];
......
......@@ -87,8 +87,7 @@ unless (Conf::load()) {
Conf::get_sympa_conf();
}
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'bulk');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
my $mailer = Sympa::Mailer->instance;
......@@ -137,8 +136,7 @@ unless ($main::options{'debug'} || $main::options{'foreground'}) {
die sprintf 'Cannot fork: %s', $ERRNO;
}
}
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'bulk');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
## If process is running in foreground, don't write STDERR to a dedicated file
my $options;
$options->{'stderr_to_tty'} = 1 if ($main::options{'foreground'});
......
......@@ -173,8 +173,11 @@ if ($main::options{'help'}) {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa/health_check');
Log::do_openlog(
$Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'},
service => 'sympa/health_check'
);
## Setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
......@@ -236,9 +239,7 @@ my $mailer = Sympa::Mailer->instance;
_load();
my $service = 'sympa';
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
$service);
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# Set the User ID & Group ID for the process
$GID = $EGID = (getgrnam(Sympa::Constants::GROUP))[2];
......@@ -1006,8 +1007,7 @@ sub _load {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# Enable SMTP logging if required
$mailer->{log_smtp} = $main::options{'mail'}
......
......@@ -112,11 +112,9 @@ unless ($main::options{'foreground'}) {
}
my $service = 'sympa/automatic';
my $pidfile = 'sympa_automatic';
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
$service);
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# If process is running in foreground, don't write STDERR to a
# dedicated file
......@@ -317,8 +315,7 @@ sub _load {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa/automatic');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# Enable SMTP logging if required
$mailer->{log_smtp} = $main::options{'mail'}
......
......@@ -144,11 +144,9 @@ unless ($main::options{'foreground'}) {
}
}
my $service = 'sympa/msg';
my $pidfile = 'sympa_msg';
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
$service);
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# If process is running in foreground, don't write STDERR to a
# dedicated file
......@@ -192,7 +190,7 @@ unless ($main::options{'foreground'}) {
Sympa::Tools::Daemon::direct_stderr_to_file(pid => $PID);
$daemon_usage = 'DAEMON_SLAVE'; # child
Log::do_openlog($Conf::Conf{'syslog'},
$Conf::Conf{'log_socket_type'}, $service);
$Conf::Conf{'log_socket_type'});
Log::do_log('info', 'Slave daemon started with PID %s', $PID);
last;
}
......@@ -437,8 +435,7 @@ sub _load {
}
## Open the syslog and say we're read out stuff.
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa/msg');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# Enable SMTP logging if required
$mailer->{log_smtp} = $main::options{'mail'}
......
......@@ -74,8 +74,7 @@ unless (Conf::load()) {
exit 1;
}
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'},
'sympa_newaliases');
Log::do_openlog($Conf::Conf{'syslog'}, $Conf::Conf{'log_socket_type'});
# setting log_level using conf unless it is set by calling option
if (defined $main::options{'log_level'}) {
......
......@@ -87,11 +87,7 @@ unless (Conf::load()) {
Conf::get_sympa_conf();
}
Log::do_openlog(
$Conf::Conf{'log_facility'},
$Conf::Conf{'log_socket_type'},
'task_manager'
);
Log::do_openlog($Conf::Conf{'log_facility'}, $Conf::Conf{'log_socket_type'});
# setting log_level using conf unless it is set by calling option
if ($main::options{'log_level'}) {
......
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