Ejemplo n.º 1
0
 /**
  * @param string $sDesc
  * @param int $iLogLevel = ELogLevel::Full
  * @param string $sFilePrefix = ''
  * @param bool $bIdDb = false
  */
 public static function Log($sDesc, $iLogLevel = ELogLevel::Full, $sFilePrefix = '')
 {
     static $bIsFirst = true;
     $oSettings =& CApi::GetSettings();
     if ($oSettings && $oSettings->GetConf('EnableLogging') && ($iLogLevel <= $oSettings->GetConf('LoggingLevel') || ELogLevel::Spec === $oSettings->GetConf('LoggingLevel') && isset($_COOKIE['SpecifiedUserLogging']) && '1' === (string) $_COOKIE['SpecifiedUserLogging'])) {
         $sLogFile = self::GetLogFileName($sFilePrefix);
         $sGuid = \MailSo\Log\Logger::Guid();
         $aMicro = explode('.', microtime(true));
         $sDate = gmdate('H:i:s.') . str_pad(isset($aMicro[1]) ? substr($aMicro[1], 0, 2) : '0', 2, '0');
         if ($bIsFirst) {
             $sUri = api_Utils::RequestUri();
             $bIsFirst = false;
             $sPost = isset($_POST) && count($_POST) > 0 ? '[POST(' . count($_POST) . ')]' : '[GET]';
             CApi::LogOnly(API_CRLF . '[' . $sDate . '][' . $sGuid . '] ' . $sPost . '[ip:' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown') . '] ' . $sUri, $sLogFile);
             if (!empty($sPost)) {
                 if (CApi::GetConf('labs.log.post-view', false)) {
                     CApi::LogOnly('[' . $sDate . '][' . $sGuid . '] POST > ' . print_r($_POST, true), $sLogFile);
                 } else {
                     CApi::LogOnly('[' . $sDate . '][' . $sGuid . '] POST > [' . implode(', ', array_keys($_POST)) . ']', $sLogFile);
                 }
             }
             CApi::LogOnly('[' . $sDate . '][' . $sGuid . ']', $sLogFile);
             //				@register_shutdown_function('CApi::LogEnd');
         }
         CApi::LogOnly('[' . $sDate . '][' . $sGuid . '] ' . (is_string($sDesc) ? $sDesc : print_r($sDesc, true)), $sLogFile);
     }
 }