summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-02-08 14:13:01 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-02-08 14:13:01 +0000
commit510a3116efe17e4bfb5a9243a6611cbad52ffe73 (patch)
treea1e59410a5e7dd7b803d94c0816225dd32fd1bae
parenteb57d050566ca0cb78d267ef494b95dbcca05109 (diff)
downloadurpmi-510a3116efe17e4bfb5a9243a6611cbad52ffe73.tar
urpmi-510a3116efe17e4bfb5a9243a6611cbad52ffe73.tar.gz
urpmi-510a3116efe17e4bfb5a9243a6611cbad52ffe73.tar.bz2
urpmi-510a3116efe17e4bfb5a9243a6611cbad52ffe73.tar.xz
urpmi-510a3116efe17e4bfb5a9243a6611cbad52ffe73.zip
Remove default logging to /var/log/urpmi.log.
Add an interface to syslog in urpm::msg. Make --env verify if env dir exists.
-rw-r--r--pod/urpmi.8.pod2
-rw-r--r--urpm/msg.pm18
-rwxr-xr-xurpmi8
3 files changed, 18 insertions, 10 deletions
diff --git a/pod/urpmi.8.pod b/pod/urpmi.8.pod
index bdcb0240..4ba8a736 100644
--- a/pod/urpmi.8.pod
+++ b/pod/urpmi.8.pod
@@ -389,7 +389,7 @@ Urpmi database locked.
=item 8
-Unable to create bug report.
+Unable to read or create bug report.
=item 9
diff --git a/urpm/msg.pm b/urpm/msg.pm
index 18053e13..5d633ace 100644
--- a/urpm/msg.pm
+++ b/urpm/msg.pm
@@ -7,7 +7,7 @@ use Exporter;
(our $VERSION) = q$Id$ =~ /(\d+\.\d+)/;
our @ISA = 'Exporter';
-our @EXPORT = qw(N log_it to_utf8 message_input message toMb from_utf8);
+our @EXPORT = qw(N bug_log to_utf8 message_input message toMb from_utf8 sys_log);
#- I18N.
use Locale::gettext;
@@ -46,8 +46,18 @@ sub N {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
+eval {
+ require Sys::Syslog;
+ Sys::Syslog->import();
+ (my $tool = $0) =~ s!.*/!!;
+ openlog($tool, '', 'user');
+ END { closelog() }
+};
+
+sub sys_log { defined &syslog and syslog("info", @_) }
+
#- writes only to logfile, not to screen
-sub log_it {
+sub bug_log {
if ($::logfile) {
open my $fh, ">>$::logfile"
or die "Can't output to log file [$::logfile]: $!\n";
@@ -68,13 +78,13 @@ sub message_input {
print ::SAVEOUT $msg;
}
if ($default_input) {
- $urpm::args::options{bug} and log_it($default_input);
+ $urpm::args::options{bug} and bug_log($default_input);
return $default_input;
}
$input = <STDIN>;
defined $input or return undef;
chomp $input;
- $urpm::args::options{bug} and log_it($input);
+ $urpm::args::options{bug} and bug_log($input);
if ($opts{boolean}) {
$input =~ /^[$noexpr$yesexpr]?$/ and last;
} elsif ($opts{range}) {
diff --git a/urpmi b/urpmi
index cf963684..911341de 100755
--- a/urpmi
+++ b/urpmi
@@ -225,6 +225,7 @@ if ($bug) {
}
if ($env) {
+ -d $env or $urpm->{fatal}(8, N("Environment directory %s does not exist", $env));
print STDERR N("using specific environment on %s\n", $env);
$logfile = "$env/urpmi_env.log";
unlink $logfile;
@@ -237,9 +238,6 @@ if ($env) {
if ($< != 0) {
#- need to be root if binary rpms are to be installed
$auto_select || @names || @files and $urpm->{fatal}(1, N("Only superuser is allowed to install packages"));
- } else {
- #- default log file
- $logfile ||= "/var/log/urpmi.log";
}
}
@@ -253,7 +251,7 @@ my ($pid_out, $pid_err);
open SAVEOUT, ">&STDOUT"; select SAVEOUT; $| = 1;
open SAVEERR, ">&STDERR"; select SAVEERR; $| = 1;
if ($logfile && !$INC{"Devel/Trace.pm"}) {
- log_it(scalar localtime, " urpmi called with $command_line\n");
+ bug_log(scalar localtime, " urpmi called with $command_line\n");
#- fork twice to copy stdout and stderr to $logfile
unless ($pid_out = open STDOUT, "|-") {
@@ -680,7 +678,7 @@ foreach my $set (@{$state->{transaction} || []}) {
}
my $to_remove = $urpm->{options}{'allow-force'} ? [] : ($set->{remove} || []);
@$to_remove and message(N("removing %s", "@$to_remove"));
- log_it(scalar localtime, " ", join(' ', values %transaction_sources_install, values %transaction_sources), "\n");
+ bug_log(scalar localtime, " ", join(' ', values %transaction_sources_install, values %transaction_sources), "\n");
$urpm->{log}("starting installing packages");
my %install_options_common = (
test => $test,