summaryrefslogtreecommitdiffstats
path: root/perl-install/log.pm
blob: e29dc410e4a28c58e18f1f0dd5b467bf835ebbfc (plain)
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
package log;

use diagnostics;
use strict;


#-#####################################################################################
#- Globals
#-#####################################################################################
my $logOpen = 0;
my $logDebugMessages = 0;


#-######################################################################################
#- Functions
#-######################################################################################
sub fd() { fileno LOG }

sub l {
    $logOpen or openLog();
    print LOG "* ", @_, "\n";
    print LOG2 "* ", @_, "\n";
}
sub ld { $logDebugMessages and &l }
sub w { &l }

sub openLog(;$) {
    if ($::isStandalone) {
	open LOG, ">&STDERR";
    } elsif ($_[0]) { #- useLocal
	open LOG, "> $_[0]";# or die "no log possible :(";
    } else {
	open LOG, "> /dev/tty3" or open LOG, ">> /tmp/install.log";# or die "no log possible :(";
    }
    open LOG2, ">> /tmp/ddebug.log";# or die "no log possible :(";
    select((select(LOG), $| = 1)[0]);
    select((select(LOG2), $| = 1)[0]);
    exists $ENV{DEBUG} and $logDebugMessages = 1;
    $logOpen = 1;
}

sub closeLog() { close LOG; close LOG2; }

#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
1;