Source

Kephra / lib / Kephra / Log.pm

use strict;
use warnings;
use Kephra::API;

package Kephra::Log;

our $level;
our @output;

sub init {}

sub warning { 
	my $msg = message( $_[0] );
	warn $msg;
	Kephra::API::output('warn', $msg);
}

sub error { 
	my $msg = message( $_[0] );
	die $msg;
}

sub message     { timestamp() . ' ' . calling_sub(3) . ': "'. $_[0].'"' }
sub timestamp   { sprintf("[%02u:%02u:%02u]", (localtime)[2,1,0]) }
sub calling_sub { ( caller($_[0]) )[0] . '::' . ( caller($_[0]) )[3] } 

1;