Support for sprintf style LogData

This commit is contained in:
Ryan Shepherd 2018-09-24 11:10:40 -04:00
parent 67aa587eb6
commit 0bb6f4b2cc
1 changed files with 4 additions and 6 deletions

View File

@ -26,17 +26,15 @@ $LogLevel = DEBUG;
@EXPORT = qw/DEBUG INFO STATUS WARN ERROR CRIT FATAL LogData/;
sub LogData {
my($level, $log, $file, $line)=@_;
if(!$file || !$line) {
my($level, $log, @args)=@_;
my($file, $line);
(undef, $file, $line)=caller();
}
if($level < DEBUG || $level > FATAL) {
LogData(ERROR, "Invalid log level, Next log.", $file, $line);
$level = FATAL;
}
return if($level < $LogLevel);
my $str = sprintf("[%6s] %s %s\n", $debugnames[$level], scalar localtime(), $log);
my $str = sprintf("[%6s] %s $log\n", $debugnames[$level], scalar localtime(), @args);
my $stack;
if($level >= $StackTraceLevel) {