當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ZLog類代碼示例

本文整理匯總了PHP中ZLog的典型用法代碼示例。如果您正苦於以下問題:PHP ZLog類的具體用法?PHP ZLog怎麽用?PHP ZLog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ZLog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Handle

 /**
  * Handles the GetAttachment command
  *
  * @param int       $commandCode
  *
  * @access public
  * @return boolean
  */
 public function Handle($commandCode)
 {
     $attname = Request::GetGETAttachmentName();
     if (!$attname) {
         return false;
     }
     try {
         $attachment = self::$backend->GetAttachmentData($attname);
         $stream = $attachment->data;
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment stream from backend: %s", $stream));
         header("Content-Type: application/octet-stream");
         $l = 0;
         while (!feof($stream)) {
             $d = fgets($stream, 4096);
             $l += strlen($d);
             echo $d;
             // announce an update every 100K
             if ($l / 1024 % 100 == 0) {
                 self::$topCollector->AnnounceInformation(sprintf("Streaming attachment: %d KB sent", round($l / 1024)));
             }
         }
         fclose($stream);
         self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", $l / 1024), true);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", $l / 1024));
     } catch (StatusException $s) {
         // StatusException already logged so we just need to pass it upwards to send a HTTP error
         throw new HTTPReturnCodeException($s->getMessage(), HTTP_CODE_500, null, LOGLEVEL_DEBUG);
     }
     return true;
 }
開發者ID:karanikn,項目名稱:php-addressbook,代碼行數:38,代碼來源:getattachment.php

示例2: OXreq

 public function OXreq($requestOBJ, $returnResponseObject)
 {
     $requestOBJ->setCookieJar($this->cookiejar);
     $requestOBJ->setHeader('User-Agent: z-push-ox (Version ' . BackendOX::getBackendVersion() . ')');
     $response = $requestOBJ->send();
     $this->cookiejar = $requestOBJ->getCookieJar();
     if ($returnResponseObject) {
         return $response;
     }
     if (200 != $response->getStatus()) {
         ZLog::Write(LOGLEVEL_WARN, 'BackendOX::OXreq(error: ' . $response->getBody() . ')');
         return false;
     }
     try {
         $data = json_decode($response->getBody(), true);
         if (is_array($data) && array_key_exists("error", $data)) {
             ZLog::Write(LOGLEVEL_WARN, 'BackendOX::OXreq(error: ' . $response->getBody() . ')');
             return false;
         } else {
             return $data;
         }
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:aniesshsethh,項目名稱:z-push-ox,代碼行數:25,代碼來源:OXConnector.php

示例3: zarafa_error_handler

function zarafa_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
    $bt = debug_backtrace();
    switch ($errno) {
        case 8192:
            // E_DEPRECATED since PHP 5.3.0
            // do not handle this message
            break;
        case E_NOTICE:
        case E_WARNING:
            // TODO check if there is a better way to avoid these messages
            if (stripos($errfile, 'interprocessdata') !== false && stripos($errstr, 'shm_get_var()') !== false) {
                break;
            }
            ZLog::Write(LOGLEVEL_WARN, "{$errfile}:{$errline} {$errstr} ({$errno})");
            break;
        default:
            ZLog::Write(LOGLEVEL_ERROR, "trace error: {$errfile}:{$errline} {$errstr} ({$errno}) - backtrace: " . (count($bt) - 1) . " steps");
            for ($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) {
                $file = $line = "unknown";
                if (isset($bt[$i]['file'])) {
                    $file = $bt[$i]['file'];
                }
                if (isset($bt[$i]['line'])) {
                    $line = $bt[$i]['line'];
                }
                ZLog::Write(LOGLEVEL_ERROR, "trace: {$i}:" . $file . ":" . $line . " - " . (isset($bt[$i]['class']) ? $bt[$i]['class'] . $bt[$i]['type'] : "") . $bt[$i]['function'] . "()");
            }
            //throw new Exception("An error occured.");
            break;
    }
}
開發者ID:SvKn,項目名稱:Z-Push-contrib,代碼行數:32,代碼來源:zpush-utils.php

示例4: Handle

 /**
  * Handles a webservice command
  *
  * @param int       $commandCode
  *
  * @access public
  * @return boolean
  * @throws SoapFault
  */
 public function Handle($commandCode)
 {
     if (Request::GetDeviceType() !== "webservice" || Request::GetDeviceID() !== "webservice") {
         throw new FatalException("Invalid device id and type for webservice execution");
     }
     if (Request::GetGETUser() != Request::GetAuthUser()) {
         ZLog::Write(LOGLEVEL_INFO, sprintf("Webservice::HandleWebservice('%s'): user '%s' executing action for user '%s'", $commandCode, Request::GetAuthUser(), Request::GetGETUser()));
     }
     // initialize non-wsdl soap server
     $this->server = new SoapServer(null, array('uri' => "http://z-push.sf.net/webservice"));
     // the webservice command is handled by its class
     if ($commandCode == ZPush::COMMAND_WEBSERVICE_DEVICE) {
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode));
         include_once 'webservicedevice.php';
         $this->server->setClass("WebserviceDevice");
     }
     // the webservice command is handled by its class
     if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) {
         if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true) {
             throw new HTTPReturnCodeException(sprintf("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS.", Request::GetAuthUser()), 403);
         }
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceUsers service", $commandCode));
         if (ZPush::GetBackend()->Setup("SYSTEM", true) == false) {
             throw new AuthenticationRequiredException(sprintf("User '%s' has no admin privileges", Request::GetAuthUser()));
         }
         include_once 'webserviceusers.php';
         $this->server->setClass("WebserviceUsers");
     }
     $this->server->handle();
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): sucessfully sent %d bytes", $commandCode, ob_get_length()));
     return true;
 }
開發者ID:alanturing1,項目名稱:Z-Push-contrib,代碼行數:41,代碼來源:webservice.php

示例5: DoForcePingTimeout

 /**
  * Checks if there are newer ping requests for the same device & user so
  * the current process could be terminated
  *
  * @access public
  * @return boolean true if the current process is obsolete
  */
 public function DoForcePingTimeout()
 {
     while (true) {
         self::$redis->watch($this->key);
         $savedtime = self::$redis->get($this->key);
         if ($savedtime === false || $savedtime < $_SERVER['REQUEST_TIME']) {
             $res = self::$redis->multi()->setex($this->key, self::TTL, $_SERVER['REQUEST_TIME'])->exec();
             if ($res === false) {
                 ZLog::Write(LOGLEVEL_DEBUG, "DoForcePingTimeout(): set just failed, retrying");
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("DoForcePingTimeout() key: '%s' reqtime: '%s' last_error: '%s'", $this->key, $_SERVER['REQUEST_TIME'], self::$redis->getLastError()));
                 continue;
             } else {
                 return false;
             }
         }
         // Don't compare types, only values
         if ($savedtime == $_SERVER['REQUEST_TIME']) {
             self::$redis->unwatch();
             return false;
         }
         if ($savedtime > $_SERVER['REQUEST_TIME']) {
             self::$redis->unwatch();
             return true;
         }
     }
 }
開發者ID:SvKn,項目名稱:Z-Push-contrib,代碼行數:33,代碼來源:PingTrackingRedis.php

示例6: Handle

 /**
  * Handles the GetAttachment command
  *
  * @param int       $commandCode
  *
  * @access public
  * @return boolean
  */
 public function Handle($commandCode)
 {
     $attname = Request::GetGETAttachmentName();
     if (!$attname) {
         return false;
     }
     try {
         $attachment = self::$backend->GetAttachmentData($attname);
         $stream = $attachment->data;
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment stream from backend: %s", $stream));
         // need to check for a resource here, as eg. feof('Error') === false and causing infinit loop in while!
         if (!is_resource($stream)) {
             throw new StatusException(sprintf("HandleGetAttachment(): No stream resource returned by backend for attachment: %s", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
         }
         header("Content-Type: application/octet-stream");
         self::$topCollector->AnnounceInformation("Starting attachment streaming", true);
         $l = fpassthru($stream);
         fclose($stream);
         if ($l === false) {
             throw new FatalException("HandleGetAttachment(): fpassthru === false !!!");
         }
         self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", round($l / 1024)), true);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", round($l / 1024)));
     } catch (StatusException $s) {
         // StatusException already logged so we just need to pass it upwards to send a HTTP error
         throw new HTTPReturnCodeException($s->getMessage(), HTTP_CODE_500, null, LOGLEVEL_DEBUG);
     }
     return true;
 }
開發者ID:EGroupware,項目名稱:z-push,代碼行數:37,代碼來源:getattachment.php

示例7: ZLog

 /**
  * Get ZLog instance
  * @return ZLog
  */
 public static function &getInstance()
 {
     if (self::$m_instance == null) {
         self::$m_instance = new ZLog();
     }
     return self::$m_instance;
 }
開發者ID:BGCX261,項目名稱:zoombi-svn-to-git,代碼行數:11,代碼來源:log.php

示例8: Block

 /**
  * Blocks the mutex
  * Method blocks until mutex is available!
  * ATTENTION: make sure that you *always* release a blocked mutex!
  *
  * @access public
  * @return boolean
  */
 public function Block()
 {
     if ($this->IsActive()) {
         return $this->blockMutex();
     }
     ZLog::Write(LOGLEVEL_WARN, "Could not enter mutex as InterProcessData is not available. This is not recommended on duty systems and may result in corrupt user/device linking!");
     return true;
 }
開發者ID:karanikn,項目名稱:php-addressbook,代碼行數:16,代碼來源:simplemutex.php

示例9: __construct

 public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false)
 {
     if (!$message) {
         $message = $this->httpReturnMessage;
     }
     if (!$logLevel) {
         $logLevel = $this->defaultLogLevel;
     }
     parent::__construct($message, (int) $code);
     ZLog::Write($logLevel, get_class($this) . ': ' . $message . ' - code: ' . $code . ' - file: ' . $this->getFile() . ':' . $this->getLine(), false);
 }
開發者ID:EGroupware,項目名稱:z-push,代碼行數:11,代碼來源:zpushexception.php

示例10: onTask

 public function onTask($server, $taskId, $fromId, $data)
 {
     Request::parse($data);
     Request::addParams('taskId', $taskId . '_' . $fromId);
     try {
         ZRoute::route();
     } catch (\Exception $e) {
         $model = Formater::exception($e);
         ZLog::info('exception', $model);
     }
 }
開發者ID:jonny77,項目名稱:zmail,代碼行數:11,代碼來源:Tcp.php

示例11: ZPushException

 public function ZPushException($message = "", $code = 0, $previous = NULL, $logLevel = false)
 {
     if (!$message) {
         $message = $this->httpReturnMessage;
     }
     if (!$logLevel) {
         $logLevel = $this->defaultLogLevel;
     }
     ZLog::Write($logLevel, get_class($this) . ': ' . $message . ' - code: ' . $code);
     parent::__construct($message, (int) $code);
 }
開發者ID:karanikn,項目名稱:php-addressbook,代碼行數:11,代碼來源:zpushexception.php

示例12: ZPushException

 public function ZPushException($message = "", $code = 0, $previous = NULL, $logLevel = false)
 {
     if (!$message) {
         $message = $this->httpReturnMessage;
     }
     if (!$logLevel) {
         $logLevel = $this->defaultLogLevel;
     }
     ZLog::Write($logLevel, sprintf("%s: %s - code: %s - file: %s:%s", get_class($this), $message, $code, $this->getFile(), $this->getLine()), false);
     parent::__construct($message, (int) $code);
 }
開發者ID:SvKn,項目名稱:Z-Push-contrib,代碼行數:11,代碼來源:zpushexception.php

示例13: Check

 /**
  * Method checks if the object has the minimum of required parameters
  * and fullfills semantic dependencies
  *
  * This overloads the general check() with special checks to be executed
  *
  * @param boolean   $logAsDebug     (opt) default is false, so messages are logged in WARN log level
  *
  * @access public
  * @return boolean
  */
 public function Check($logAsDebug = false)
 {
     $ret = parent::Check($logAsDebug);
     if (!$ret) {
         return false;
     }
     if (isset($this->start) && isset($this->until) && $this->until < $this->start) {
         ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'start' is HIGHER than 'until'. Check failed!", get_class($this)));
         return false;
     }
     return true;
 }
開發者ID:netconstructor,項目名稱:sogosync,代碼行數:23,代碼來源:synctaskrecurrence.php

示例14: stream_open

 /**
  * Opens the stream
  * The string to be streamed is passed over the context
  *
  * @param string    $path           Specifies the URL that was passed to the original function
  * @param string    $mode           The mode used to open the file, as detailed for fopen()
  * @param int       $options        Holds additional flags set by the streams API
  * @param string    $opened_path    If the path is opened successfully, and STREAM_USE_PATH is set in options,
  *                                  opened_path should be set to the full path of the file/resource that was actually opened.
  *
  * @access public
  * @return boolean
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     $contextOptions = stream_context_get_options($this->context);
     if (!isset($contextOptions[self::PROTOCOL]['string'])) {
         return false;
     }
     $this->position = 0;
     // this is our stream!
     $this->stringstream = $contextOptions[self::PROTOCOL]['string'];
     $this->stringlength = strlen($this->stringstream);
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("StringStreamWrapper::stream_open(): initialized stream length: %d", $this->stringlength));
     return true;
 }
開發者ID:netconstructor,項目名稱:sogosync,代碼行數:26,代碼來源:stringstreamwrapper.php

示例15: Open

 /**
  * Instantiates a stream
  *
  * @param string $string  The string to be wrapped
  * @access public
  * @return stream
  */
 public static function Open($string)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("StringStreamWrapper::Open(): len = %d", strlen($string)));
     if (defined('BUG68532FIXED') && BUG68532FIXED === true) {
         ZLog::Write(LOGLEVEL_DEBUG, "StringStreamWrapper::Open(): Using php://temp");
         $stream = fopen('php://temp', 'r+');
     } else {
         ZLog::Write(LOGLEVEL_DEBUG, "StringStreamWrapper::Open(): Using tmpfile()");
         $stream = tmpfile();
     }
     fwrite($stream, $string);
     rewind($stream);
     return $stream;
 }
開發者ID:SvKn,項目名稱:Z-Push-contrib,代碼行數:21,代碼來源:stringstreamwrapper.php


注:本文中的ZLog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。