Description

Alexya's Database Logger.

Implements a PSR compatible database logger.

The constructor accepts as parameter the following parameters:

The \Alexya\Database\Connection object that will be used for interacting with the database. A string being the table name. An associative array containing the columns and the values to insert, you can insert the following placeholders: {YEAR}, current year. {MONTH}, current month. {DAY}, current day. {HOUR}, current hour. {MINUTE}, current minute. {SERVER_NAME}, server's name (localhost, test.com...). {CALLING_FUNCTION}, the function that called the logger. {CALLING_FILE}, the file that called the logger. {CALLING_LINE}, the line that called the logger. {CALLING_CLASS}, the class that called the logger. {CALLING_TYPE}, -> if the logger was called by an object, :: if it was called statically. {LEVEL}, the level on which the log has been called. {LOG}, the string to log. A string being the format that each log entry will have, you can add the following placeholders: {YEAR}, current year. {MONTH}, current month. {DAY}, current day. {HOUR}, current hour. {MINUTE}, current minute. {SERVER_NAME}, server's name (localhost, test.com...). {CALLING_FUNCTION}, the function that called the logger. {CALLING_FILE}, the file that called the logger. {CALLING_LINE}, the line that called the logger. {CALLING_CLASS}, the class that called the logger. {CALLING_TYPE}, -> if the logger was called by an object, :: if it was called statically. {LEVEL}, the level on which the log has been called. {LOG}, the string to log. An array containing the elements that will be logged, you can get a full list of available values in the class \Psr\Log\LogLevel

The method log performs the actual logging and accepts as parameter the log level (see \Psr\Log\LogLevel for a list of possible values) and the string to log.

There are also 8 methods for logging in a specific category: emergency alert critical error warning notice info debug

All of them accepts as parameter the last 2 parameters of the log method.

Example:

$Logger = new Logger(
$Database,
"logs",
[
"date"    => "{YEAR}-{MONTH}-{DAY} {HOUR}:{MINUTE}:{SECOND}",
"caller"  => "{CALLER_CLASS}{CALLER_TYPE}{CALLER_FUNCTION} ({CALLER_FILE}:{CALLER_LINE})",
"level"   => "{LEVEL}",
"message" => "{LOG}"
],
[
\Psr\Log\LogLevel::EMERGENCY,
\Psr\Log\LogLevel::ALERT,
\Psr\Log\LogLevel::CRITICAL,
\Psr\Log\LogLevel::ERROR,
\Psr\Log\LogLevel::WARNING,
\Psr\Log\LogLevel::NOTICE,
\Psr\Log\LogLevel::INFO,
\Psr\Log\LogLevel::DEBUG
]
);

$Logger->debug("test"); // INSERT INTO `logs` (`date`, `caller`, `level`, `message`) VALUES ('0000-00-00 00:00:00', '', 'debug', 'test');
$Logger->info("test", [
"date"    => "{HOUR}:{MINUTE}:{SECOND}",
"caller"  => "{CALLER_CLASS}{CALLER_TYPE}{CALLER_FUNCTION} ({CALLER_FILE}:{CALLER_LINE})",
"level"   => "{LEVEL}",
"message" => "{LOG}"
]); // INSERT INTO `logs` (`date`, `caller`, `level`, `message`) VALUES ('00:00:00', '', 'debug', 'test');

Type hierarchy

psr/log dev-master 1.1.0
View more packages
mediawiki/mediawiki-core-vendor dev-master
farmani/yii2-resque dev-master v1.2.2
imdbphp/imdbphp v4.1.x-dev v4.1.1
minchal/vero dev-master
resque/yii2-resque dev-master
sammet/gestion-colecciones dev-master
zzh-php/lib dev-master 1.1.0.x-dev
datasift/stone dev-master 1.10.3
lionsad/service_container 1.0.0-beta5
lionsad/service_container_libraries dev-master
gbv/jskos 0.1.11
slime/slime_interface dev-master 0.1
instituteweb/typo3-cms 6.2.31
goragod/kotchasan 1.0.0.x-dev dev-master
integer-net/solr-base 2.1.0 1.0.4 dev-master 3.3.0
amzn/login-and-pay-with-amazon-sdk-php 2.x-dev
psr-php7/log dev-master 1.0.0
amzn/amazon-pay-sdk-php 2.x-dev
typo3/cms 6.2.31
redweb-tn/codeigniter4 dev-master 4.0
redweb-tn/framework dev-master 4.0
codeigniter4/framework dev-master 1.0 v4.0.0-alpha.5
rkr/amazon-pay-sdk-php 2.x-dev
ortnit/logger dev-master
mrcnpdlk/imdbphp v4.1.1
deathart/blogci4 dev-master
kaidenchen/yii2-resque-enhance dev-master 1.0 v0.2
instrye/cloudflare-partners-ci4 dev-master
psr/log dev-master 1.1.0
View more packages
mediawiki/mediawiki-core-vendor dev-master
farmani/yii2-resque dev-master v1.2.2
minchal/vero dev-master
resque/yii2-resque dev-master
lionsad/service_container 1.0.0-beta5
lionsad/service_container_libraries dev-master
amzn/login-and-pay-with-amazon-sdk-php 2.x-dev
gbv/jskos 0.1.11
slime/slime_interface dev-master 0.1
amzn/amazon-pay-sdk-php 2.x-dev
goragod/kotchasan dev-master
integer-net/solr-base 2.1.0 1.0.4 dev-master 3.3.0
psr-php7/log dev-master 1.0.0
redweb-tn/codeigniter4 dev-master 4.0
redweb-tn/framework dev-master 4.0
codeigniter4/framework dev-master 1.0 v4.0.0-alpha.5
rkr/amazon-pay-sdk-php 2.x-dev
ortnit/logger dev-master
deathart/blogci4 dev-master
kaidenchen/yii2-resque-enhance dev-master 1.0 v0.2
instrye/cloudflare-partners-ci4 dev-master

Class usage:

This class is not referred by any other class/interface/traits in packagist packages.