Skip to content

Commit

Permalink
utils.pm - add print_log and print_error.
Browse files Browse the repository at this point in the history
  • Loading branch information
soarpenguin committed Jan 8, 2014
1 parent 1e8f962 commit 0cac51f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions utils.pm
Expand Up @@ -189,6 +189,33 @@ sub get_now_time {
return "[$now_time]";
}

sub print_error
{
my ($string,$string2, $file, $line) = @_;
use File::Basename;
$file = basename($file);
chomp $string;

print STDOUT get_now_time() . $string . "[" . $file . ":" . $line ."]".$string2."\n";

}

# print_log("[Notice][name]","xxxx", __FILE__, __LINE__);
sub print_log
{
my ($method,$string, $file, $line) = @_;
use File::Basename;
$file = basename($file);
chomp $string;
my $components = '[Trace][';
if($method eq 'main'){
$components .='main]'
} else{
$components .= $method."]";
}
print STDOUT get_now_time() . $components . "[" . $file . ":" . $line ."]" . $string."\n";
}

sub trim
{
my $string = shift;
Expand Down

0 comments on commit 0cac51f

Please sign in to comment.