Last active
April 28, 2018 16:20
-
-
Save im-samir-dev/99ea8f67ed7fcb06a7ead23c74da15bd to your computer and use it in GitHub Desktop.
PHP logger function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//NOTE: For use the Logger function copy these two lines to your code and fill $LOGGER_VARIABLES array by your variables | |
/* | |
$LOGGER_VARIABLES = []; | |
LOGGER(__FILE__, __METHOD__, __LINE__, function () use ($LOGGER_VARIABLES) {var_dump($LOGGER_VARIABLES);}); | |
*/ | |
//NOTE: PHP error reporter | |
//error_reporting(E_ALL); | |
error_reporting(E_ALL ^ E_STRICT); | |
ini_set('display_errors', 'On'); | |
//NOTE: Logger Function | |
/** | |
* @param string $fileName | |
* @param string $methodName | |
* @param int $lineNo | |
* @param callable $message | |
*/ | |
function LOGGER($fileName, $methodName, $lineNo, callable $message) | |
{ | |
echo "<div style='margin: 20px 5px; padding: 5px; background-color: #dddddd; border: 1px solid black;'><div style='color: red;'>"; | |
echo "LOG|" . pathinfo($fileName, PATHINFO_BASENAME) . "|" . $methodName . "|" . $lineNo . ":"; | |
echo "</div>"; | |
$message(); | |
echo "<div style='color: red;'>:LOG</div></div>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment