1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package log; # $Id: log.pm 215411 2007-04-25 12:26:16Z pixel $
use diagnostics;
use strict;
use c;
my ($LOG, $LOG2);
sub l {
if ($::testing) {
print STDERR @_, "\n";
} elsif ($::isInstall) {
if (!$LOG) {
open $LOG, '>>', '/tmp/ddebug.log';
open $LOG2, '>', '/dev/tty3' if !$::local_install;
select((select($LOG), $| = 1)[0]);
select((select($LOG2), $| = 1)[0]) if !$::local_install;
}
print $LOG "* ", @_, "\n";
print $LOG2 "* ", @_, "\n" if $LOG2;
} elsif ($::isStandalone) {
#- openlog was done in standalone.pm
c::syslog(c::LOG_WARNING(), join("", @_));
} else {
print STDERR @_, "\n";
}
}
sub openLog {
my ($file) = @_;
open $LOG, "> $file";
select((select($LOG), $| = 1)[0]);
}
sub closeLog() {
if ($LOG) {
close $LOG;
close $LOG2 if $LOG2;
} elsif ($::isStandalone) {
c::closelog();
}
}
sub explanations {
if ($::isStandalone) {
c::syslog(c::LOG_INFO()|c::LOG_LOCAL1(), "@_");
} else {
l(@_);
}
}
1;
|