5 @EXPORT = qw (clearmsg clearlog clearlogmsg);
8 $me = substr ($0, rindex ($0, "\\") + 1);
10 # Set logfile appropriately: We use ipconfig to get the current host's
11 # IP address then determine whether we are in the US or China. If
12 # neither then we fallback to using T:/Triggers/Logs/trigger.log
13 my @ipconfig = grep (/IP Address/, `ipconfig`);
14 my ($ipaddr) = ($ipconfig[0] =~ /(\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3})/);
16 # US is in the subnets of 192 and 172 while China is in the subnet of 10
17 if ($ipaddr =~ /^192|^172/) {
18 $logfile = "//sons-clearcase/Views/official/Tools/logs/trigger.log";
19 } elsif ($ipaddr =~ /^10/) {
20 $logfile = "//sons-cc/Views/official/Tools/logs/trigger.log";
22 die "Internal Error: Unable to the trigger.log!\n"
25 $user = $ENV {CLEARCASE_USER};
29 # Display a message to the user using clearprompt
30 my ($message) = shift;
32 `clearprompt proceed -type error -prompt "$message" -mask abort -default abort`;
36 # Log a message to the log file
37 my ($message) = shift;
40 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time);
43 $hour = "0" . $hour if $hour < 10;
44 $min = "0" . $min if $min < 10;
45 $date = "$mon/$mday/$year\@$hour:$min";
47 open (LOGFILE, ">>$logfile") || die "Unable to open logfile ($logfile)\n";
49 print LOGFILE "$me: $date: $user: $message\n";
55 # Log message to log file then display it to user
56 my ($message) = shift;