Permalink
Browse files

utils.pm - add print_log and print_error.

  • Loading branch information...
1 parent 1e8f962 commit 0cac51f348ff7f1cdc760d45e9d6b2d6ebb75637 @soarpenguin committed Jan 8, 2014
Showing with 27 additions and 0 deletions.
  1. +27 −0 utils.pm
View
@@ -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;

0 comments on commit 0cac51f

Please sign in to comment.