2
# Log.pm: logging library for sbuild
3
# Copyright © 2005 Ryan Murray <rmurray@debian.org>
4
# Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see
18
# <http://www.gnu.org/licenses/>.
20
#######################################################################
29
use File::Basename qw(basename);
30
use Sbuild qw(send_mail);
42
@EXPORT = qw(open_log close_log);
50
my $main_distribution = $conf->get('DISTRIBUTION');
51
my $date = strftime("%Y%m%d-%H%M",localtime);
54
$main_logfile = undef;
56
if (!$conf->get('NOLOG')) {
57
my $F = new File::Temp( TEMPLATE => "build-${main_distribution}-$date.XXXXXX",
58
DIR => $conf->get('BUILD_DIR'),
61
or die "Can't open logfile: $!\n";
63
$main_logfile = $F->filename;
66
return Sbuild::LogBase::open_log($conf, $F, undef);
72
my $date = strftime("%Y%m%d-%H%M",localtime);
74
Sbuild::LogBase::close_log($conf);
76
if (!$conf->get('NOLOG') && !$conf->get('VERBOSE') &&
77
-s $main_logfile && $conf->get('MAILTO')) {
79
$conf->get('MAILTO'), "Log from sbuild $date",
80
$main_logfile ) if $conf->get('MAILTO');
82
elsif (!$conf->get('NOLOG') && ! -s $main_logfile) {
83
unlink( $main_logfile );