~ubuntu-branches/ubuntu/vivid/gitolite3/vivid-proposed

« back to all changes in this revision

Viewing changes to src/lib/Gitolite/Common.pm

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2014-10-06 12:30:00 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20141006123000-pzkzr0u220sjmpg7
Tags: 3.6.1-1
New upstream release (Closes: #755784)

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
}
125
125
 
126
126
sub _mkdir {
127
 
    # it's not an error if the directory exists, but it is an error if it
128
 
    # doesn't exist and we can't create it
 
127
    # It's not an error if the directory exists, but it is an error if it
 
128
    # doesn't exist and we can't create it. This includes not guaranteeing
 
129
    # dead symlinks or if mkpath traversal is blocked by a file.
129
130
    my $dir  = shift;
130
131
    my $perm = shift;    # optional
131
132
    return if -d $dir;
264
265
    return $template;
265
266
}
266
267
 
 
268
my $log_dest;
 
269
my $syslog_opened = 0;
 
270
END { closelog() if $syslog_opened; }
267
271
sub gl_log {
268
272
    # the log filename and the timestamp come from the environment.  If we get
269
273
    # called even before they are set, we have no choice but to dump to STDERR
276
280
    my $ts = gen_ts();
277
281
    my $tid = $ENV{GL_TID} ||= $$;
278
282
 
 
283
    # syslog
 
284
    $log_dest = $Gitolite::Rc::rc{LOG_DEST} || '' if not defined $log_dest;
 
285
    if ($log_dest =~ /syslog/) {            # log_dest *includes* syslog
 
286
        if ($syslog_opened == 0) {
 
287
            require Sys::Syslog;
 
288
            Sys::Syslog->import(qw(:standard));
 
289
 
 
290
            openlog("gitolite" . ( $ENV{GL_TID} ? "[$ENV{GL_TID}]" : "" ), "pid", "local0");
 
291
            $syslog_opened = 1;
 
292
        }
 
293
 
 
294
        # gl_log is called either directly, or, if the rc variable LOG_EXTRA
 
295
        # is set, from trace(1, ...).  The latter use is considered additional
 
296
        # info for troubleshooting.  Trace prefixes a tab to the arguments
 
297
        # before calling gl_log, to visually set off such lines in the log
 
298
        # file.  Although syslog eats up that leading tab, we use it to decide
 
299
        # the priority/level of the syslog message.
 
300
        syslog( ( $msg =~ /^\t/ ? 'debug' : 'info' ), "%s", $msg);
 
301
 
 
302
        return if $log_dest eq 'syslog';    # log_dest *equals* syslog
 
303
    }
 
304
 
279
305
    my $fh;
280
306
    logger_plus_stderr( "errors found before logging could be setup", "$msg" ) if not $ENV{GL_LOGFILE};
281
307
    open my $lfh, ">>", $ENV{GL_LOGFILE}