Description

Alexya's Logger.

Implements a PSR compatible file logger.

The constructor accepts as parameter the following parameters:

The \Alexya\FileSystem\File] object that will represent the path where the log files will be saved. A string being the format of each log file name, 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...). 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.

You can also send a third parameter being an array containing the placeholders to format the log, this will override the format sent in the settings, you can add your custom placeholders this way.

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 \Alexya\Logger\File(
new \Alexya\FileSystem\Directory("/tmp/log/Alexya"),
"{YEAR}-{MONTH}-{DAY}.log",
"[{HOUR}:{MINUTE}] ({LEVEL}) {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"); // [00:00] (debug) test
$Logger->info("[{HOUR}:{MINUTE}] ({LEVEL}) {CUSTOM_PLACEHOLDER}", [
"CUSTOM_PLACEHOLDER" => "test"
]); // [00:00] (debug) test

Type hierarchy

amzn/amazon-pay-sdk-php 2.x-dev
psr/log dev-master 1.1.3
View more packages
amzn/login-and-pay-with-amazon-sdk-php 2.x-dev
ortnit/logger dev-master
psr-php7/log dev-master 1.0.0
amzn/amazon-pay-sdk-php 2.x-dev
psr/log dev-master 1.1.3
View more packages
amzn/login-and-pay-with-amazon-sdk-php 2.x-dev
ortnit/logger dev-master
psr-php7/log dev-master 1.0.0

Class usage:

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