Commits

Herbert Breunung committed 3af6929

log maessages can optionally name caller of caller

Comments (0)

Files changed (2)

lib/Kephra/API.pm

 sub focus_back      { Kephra::App::Focus::set_back(@_) }
 
 # IO-unit
-sub input           { 
-	main_window()->{'part'}{'iounit'}->get_line()
-		if ref main_window() and exists main_window()->{'part'}{'iounit'}
-}
-sub output          {
-	main_window()->{'part'}{'iounit'}->output(@_)
-		if ref main_window() and exists main_window()->{'part'}{'iounit'}
-}
-sub log             { 
-	main_window()->{'part'}{'iounit'}->output('log', @_)
-		if ref main_window() and exists main_window()->{'part'}{'iounit'}
-}
+sub input  {main_window()->{'part'}{'iounit'}->get_line() if ref main_window() and exists main_window()->{'part'}{'iounit'} }
+sub output {main_window()->{'part'}{'iounit'}->output(@_) if ref main_window() and exists main_window()->{'part'}{'iounit'} }
+sub log    {main_window()->{'part'}{'iounit'}->output('log', @_) if ref main_window() and exists main_window()->{'part'}{'iounit'} }
 
 sub configs  { }
 

lib/Kephra/Log.pm

 sub init {}
 
 sub warning { 
-	my $msg = message( $_[0] );
+	my $msg = message( @_ );
 	warn $msg unless $test_mode;
 	Kephra::API::output('warn', $msg) unless $test_mode;
 }
 
 sub error { 
-	my $msg = message( $_[0] );
+	my $msg = message( @_ );
 	die $msg unless $test_mode;
 	Kephra::API::output('warn', 'ERROR: '.$msg) unless $test_mode;
 }
 
-sub message     { timestamp() . ' ' . calling_sub(3) . ': "'. $_[0].'"' }
+sub message     { 
+	my $msg = timestamp() . ' ' . calling_sub(3) . ': "'. $_[0].'"';
+	$msg .= ', when called by '. calling_sub(4) if $_[1];
+	$msg;
+}
 sub timestamp   { sprintf("[%02u:%02u:%02u]", (localtime)[2,1,0]) }
 sub calling_sub { ( caller($_[0]) )[0] . '::' . ( caller($_[0]) )[3] }