src/Logger.php
public static function add($message = 'No message', $logCode = self::LEVEL_INFO)
    {
        // if file pointer doesn't exist, then open log file  
        if (!self::$_fileHandler) {
            self::_openLogFile();
        }

        // Get user IP
        if (!empty($_SERVER['REMOTE_ADDR'])) {
            $userIP = $_SERVER['REMOTE_ADDR'];
        } else {
            $userIP = '0.0.0.0';
        }

        // define current time  
        $time = date('j/M/Y H:i:s');

        // define script name  
        $scriptName = pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME);

        // write message to the log file
        $fwrite = fwrite(self::$_fileHandler, "$userIP [$time][$logCode] ($scriptName) --> $message\n");
        
        if ($fwrite === false) {
            return false;
        } else {
            return true;
        }
    }
public static function add($message = 'No message', $logCode = self::LEVEL_INFO)
    {
        // if file pointer doesn't exist, then open log file  
        if (!self::$_fileHandler) {
            self::_openLogFile();
        }

        // Get user IP
        if (!empty($_SERVER['REMOTE_ADDR'])) {
            $userIP = $_SERVER['REMOTE_ADDR'];
        } else {
            $userIP = '0.0.0.0';
        }

        // define current time  
        $time = date('j/M/Y H:i:s');

        // define script name  
        $scriptName = pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME);

        // write message to the log file
        $fwrite = fwrite(self::$_fileHandler, "$userIP [$time][$logCode] ($scriptName) --> $message\n");
        
        if ($fwrite === false) {
            return false;
        } else {
            return true;
        }
    }
public static function add ( $ message = 'No message' , $ logCode = self :: LEVEL_INFO ) { // if file pointer doesn't exist, then open log file   if ( ! self :: $ _fileHandler ) { self :: _openLogFile ( ) ; } // Get user IP if ( ! empty ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ userIP = $ _SERVER [ 'REMOTE_ADDR' ] ; } else { $ userIP = '0.0.0.0' ; } // define current time   $ time = date ( 'j/M/Y H:i:s' ) ; // define script name   $ scriptName = pathinfo ( $ _SERVER [ 'PHP_SELF' ] , PATHINFO_BASENAME ) ; // write message to the log file $ fwrite = fwrite ( self :: $ _fileHandler , "$userIP [$time][$logCode] ($scriptName) --> $message\n" ) ; if ( $ fwrite === false ) { return false ; } else { return true ; } }
Write message to the log file
@param string $message Optional message
@param string $logCode Optional log code (example: INFO (default), ERROR, EMERGENCY)
Write message to the log file