File: log.pl

package info (click to toggle)
cbb 1%3A0.8.1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,864 kB
  • ctags: 551
  • sloc: tcl: 5,221; perl: 4,512; sh: 376; makefile: 152
file content (58 lines) | stat: -rw-r--r-- 1,748 bytes parent folder | download | duplicates (3)
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
56
57
58
#!/usr/local/bin/perl
#  log.pl - logging functions
#
#  Written by Christopher Browne.  Started November 1, 1994.
#  Modified by Curtis Olson.
#
#  Copyright (C) 1994  Christopher B. Browne cbrowne@io.org
#  Copyright (C) 1994 - 1999  Curtis L. Olson  - curt@me.umn.edu
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# $Id: log.pl,v 1.2 2000/01/02 19:08:02 curt Exp $


package CBB;

use strict;   # don't take no guff


# Create a log entry
sub log_txn {
    my($command_line) = @_;
    my($home) = &file_dirname($CBB::current_file);

    print DEBUG "File is $CBB::current_file\n" if $CBB::debug;
    print DEBUG "logging to $home/alltxns.log\n" if $CBB::debug;

    open(LOG, ">>$home/alltxns.log");
    print LOG &log_fmt_date() . " " . $command_line . "\n";
    close(LOG);

}


# return the current date/time in log format
sub log_fmt_date {
    my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) 
	= localtime(time);
    $year += 1900;

    return sprintf("%04d/%02d/%02d %02d:%02d:%02d", $year, $mon+1,
		   $mday, $hour, $min, $sec);
}


1;				# need to return a true value