当前位置: 首页>>代码示例>>PHP>>正文


PHP Logger::Log方法代码示例

本文整理汇总了PHP中Logger::Log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::Log方法的具体用法?PHP Logger::Log怎么用?PHP Logger::Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logger的用法示例。


在下文中一共展示了Logger::Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 public static function send($subject, $content)
 {
     // 十分钟一次
     $redis = Yaf\Registry::get('redis');
     $hash = $subject . '|' . intval(time() / 600);
     if ($redis->get(self::$redis_latest_mail_key) == $hash) {
         return false;
     } else {
         // send mail
         $mail = new PHPMailer();
         $mail->isSMTP();
         $mail->Host = "smtp.163.com";
         $mail->Port = 25;
         $mail->SMTPAuth = true;
         $mail->Username = "ideawebcn@163.com";
         $mail->Password = "rabbitAimsam52";
         $mail->setFrom('ideawebcn@163.com', 'AutoTrade');
         // TODO
         $mail->addAddress('', '');
         $mail->Subject = $subject;
         $mail->Body = $content;
         if ($mail->send()) {
             $redis->set(self::$redis_latest_mail_key, $hash);
             return true;
         } else {
             Logger::Log('Send mail failed' . $mail->ErrorInfo, Logger::ERROR_LOG);
             return false;
         }
     }
 }
开发者ID:Aimsam,项目名称:BTCAutoTrade,代码行数:30,代码来源:Mail.php

示例2: run

 /**
  * @desc 执行交易
  */
 public function run()
 {
     Logger::Log('Start place Order: ' . $this->__toString());
     $action = $this->action;
     usleep(400000);
     $result = $this->account->market->{$action}($this->price, $this->amount);
     Logger::Log("order result :" . var_export($result));
     //false 代表下单不成功,直接再次尝试
     //TODO 如果非常长的时间整个报警
     while ($result === false) {
         Logger::Log("Place " . get_class($this->account->market) . " order failed, try again.");
         $this->status = self::ORDER_PLACE_FAILED;
         return $this->run();
     }
     if ($result === true) {
         Logger::Log("Place " . get_class($this->account->market) . " order successful and deal!");
         //下单成功并且交易成功
         $this->status = self::ORDER_DEAL_SUCCESS;
     } else {
         $this->order_id = $result;
         Logger::Log("Place " . get_class($this->account->market) . " order successful order_id[{$this->order_id}]");
         $this->status = self::ORDER_PLACE_SUCCESS;
     }
     return null;
 }
开发者ID:Aimsam,项目名称:BTCAutoTrade,代码行数:28,代码来源:Order.php

示例3: GeocodeLocation

 public static function GeocodeLocation($locationName)
 {
     if (static::$geocoder == null) {
         static::$geocoder = new OpenCage\Geocoder(self::Key, self::Options);
     }
     Logger::Log("Resolving : " . $locationName);
     $result = static::$geocoder->geocode($locationName);
     $ret = new GeocodingResult();
     if (!isset($result)) {
         Logger::Log("Address: " . $locationName . " was not resolved: No result recieved");
     } else {
         if (isset($result) && $result['status']['message'] == "OK" && count($result['results']) > 0) {
             $ret->valid = true;
             $res = $result['results'][0]['geometry'];
             $ret->lat = $res['lat'];
             $ret->lon = $res['lng'];
             Logger::Log("Address: " . $locationName . " was resolved as: " . $res['lat'] . " , " . $res['lng']);
         } else {
             $ret->valid = false;
             $message = "«" . $result['status']['code'] . " " . $result['status']['message'] . "»";
             Logger::Log("Address: " . $locationName . " was not resolved: " . $message . ".");
         }
     }
     // Logger::Log( print_r ( $result, true ) );
     return $ret;
 }
开发者ID:aloxe,项目名称:french-voters,代码行数:26,代码来源:geocoding.php

示例4: logout

 public function logout()
 {
     $datetime = new DateTime();
     $this->logoutTime = $datetime->format('Y/m/d H:i:s a');
     Logger::Log(get_class($this), 'OK', $this->user->username . ' logs out at ' . $this->logoutTime . ' from terminal XXX');
     //$this::__destroy();
 }
开发者ID:xander-mbaka,项目名称:momentum,代码行数:7,代码来源:Session.php

示例5: Log

 public static function Log($class, $category, $message)
 {
     $datetime = new DateTime();
     $stamp = $datetime->format('YmdHis');
     try {
         $sql = 'INSERT INTO logs (class, category, message, stamp) VALUES ("' . $class . '", "' . $category . '", "' . $message . '", ' . $stamp . ')';
         DatabaseHandler::Execute($sql);
     } catch (Exception $e) {
         Logger::Log(get_class($this), 'Exception', $e->getMessage());
     }
 }
开发者ID:xander-mbaka,项目名称:momentum,代码行数:11,代码来源:Logger.php

示例6: Log

 /**
  * Logs messages depending on the ids trace level.
  *
  * @param TraceLevel $idsTraceLevel IDS Trace Level
  * @param string messageToWrite The message to write.
  */
 public function Log($idsTraceLevel, $messageToWrite)
 {
     if ((int) $this->traceSwitchLevel < (int) $idsTraceLevel) {
         return;
     }
     $backTrace = debug_backtrace();
     $callerFileName = $backTrace[0]['file'];
     $callerFileLineNumber = $backTrace[0]['line'];
     $callerFunctionName = $backTrace[0]['function'];
     $logMessage = implode(" - ", array(date('Y-m-d H:i:s'), $callerFileName, $callerFileLineNumber, $callerFunctionName, $messageToWrite));
     parent::Log($idsTraceLevel, $logMessage);
 }
开发者ID:andrewhook,项目名称:oauth-php,代码行数:18,代码来源:TraceLogger.php

示例7: checkInput

 /**
  * The function checks whether an input list of arguments, has the correct data type
  * If not, the slim instance terminates with a 412 error code
  *
  * @param Slim $app a running slim instance
  */
 public static function checkInput()
 {
     $args = func_get_args();
     // the first argument ist the slim instance, remove from the test list
     $app =& $args[0];
     $args = array_slice($args, 1, count($args));
     foreach ($args as $a) {
         // search a argument, which is not true
         if (!$a) {
             // one of the arguments isn't true, abort progress
             Logger::Log('access denied', LogLevel::ERROR);
             $app->response->setBody('[]');
             $app->response->setStatus(412);
             $app->stop();
             break;
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:24,代码来源:DBJson.php

示例8: exchange

 private function exchange($account_group_id, $to_usd_rate, $to_cny_rate)
 {
     $account_group = new AccountGroupModel($account_group_id);
     $trades = $account_group->availableTrades();
     if (count($trades) > 0) {
         foreach ($trades as $trade) {
             Logger::Log("Judge Trade: " . $trade->__toString());
             if ($trade->tacticsTransport($to_usd_rate, $to_cny_rate)) {
                 $trade->run(TradeModel::MODE_LOOSE);
                 Logger::Log('finished 1 time, next trade.');
                 return $this->runAction();
             } else {
                 Logger::Log('no chance, next trade.');
             }
         }
         return $this->exchange($account_group_id, $to_usd_rate, $to_cny_rate);
     } else {
         throw new Exception('no possible trade, fix it!');
     }
 }
开发者ID:Aimsam,项目名称:BTCAutoTrade,代码行数:20,代码来源:Transport.php

示例9: restart

 private function restart()
 {
     //暂时做个定时重启策略
     $time = time();
     $pid = getmypid();
     $hedge = json_decode(Yaf\Registry::get('redis')->get('hedge'), true);
     if (empty($hedge)) {
         Yaf\Registry::get('redis')->set('hedge', json_encode(array('time' => $time, 'pid' => $pid)));
     } else {
         if ($time - $hedge['time'] > 500) {
             Logger::Log("restart Hedge");
             $path = APPLICATION_PATH . "/scripts/Hedge";
             Yaf\Registry::get('redis')->del('hedge');
             system("{$path}");
             system("kill -9 {$hedge['pid']}");
             system("kill -9 {$pid}");
         } else {
             if ($hedge['pid'] != $pid) {
                 system("kill -9 {$hedge['pid']}");
                 Yaf\Registry::get('redis')->set('hedge', json_encode(array('time' => $time, 'pid' => $pid)));
             }
         }
     }
 }
开发者ID:Aimsam,项目名称:BTCAutoTrade,代码行数:24,代码来源:Hedge.php

示例10: handleException

 /**
  * Handle & log exceptions
  *
  * @param  Throwable  $e
  * @return void
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public static function handleException($e)
 {
     Logger::Log(get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
     self::render($e)->send();
 }
开发者ID:omarelgabry,项目名称:miniphp,代码行数:12,代码来源:Handler.php

示例11: custom

 /**
  * performs a custom request
  *
  * @param string $method the request type (POST, DELETE, PUT, GET, ...) 
  * @param string $target the taget URL
  * @param string $header an array with header informations
  * @param string $content the request content/body
  *
  * @return an array with the request result (status, header, content)
  * - ['headers'] = an array of header informations e.g. ['headers']['Content-Type']
  * - ['content'] = the response content
  * - ['status'] = the status code e.g. 200,201,404,409,...
  */
 public static function custom($method, $target, $header, $content, $authbool = true, $sessiondelete = false)
 {
     $begin = microtime(true);
     $done = false;
     if (!CConfig::$onload && strpos($target, 'http://localhost/') === 0 && file_exists(dirname(__FILE__) . '/request_cconfig.json')) {
         if (self::$components === null) {
             self::$components = CConfig::loadStaticConfig('', '', dirname(__FILE__), 'request_cconfig.json');
         }
         $coms = self::$components->getLinks();
         if ($coms != null) {
             if (!is_array($coms)) {
                 $coms = array($coms);
             }
             $e = strlen(rtrim($_SERVER['DOCUMENT_ROOT'], '/'));
             $f = substr(str_replace("\\", "/", dirname(__FILE__)), $e);
             $g = substr(str_replace("\\", "/", $_SERVER['SCRIPT_FILENAME']), $e);
             $a = 0;
             for (; $a < strlen($g) && $a < strlen($f) && $f[$a] == $g[$a]; $a++) {
             }
             $h = substr(str_replace("\\", "/", $_SERVER['PHP_SELF']), 0, $a - 1);
             foreach ($coms as $com) {
                 if ($com->getPrefix() === null || $com->getLocalPath() == null || $com->getClassFile() == null || $com->getClassName() == null) {
                     Logger::Log('nodata: ' . $method . ' ' . $target, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
                     continue;
                 }
                 $url = 'http://localhost' . $h . '/' . $com->getLocalPath();
                 if (strpos($target, $url . '/') === 0) {
                     $result = array();
                     $tar = dirname(__FILE__) . '/../' . $com->getLocalPath() . '/' . $com->getClassFile();
                     $tar = str_replace("\\", "/", $tar);
                     if (!file_exists($tar)) {
                         continue;
                     }
                     $add = substr($target, strlen($url));
                     $sid = CacheManager::getNextSid();
                     CacheManager::getTree($sid, $target, $method);
                     $cachedData = CacheManager::getCachedDataByURL($sid, $target, $method);
                     if ($cachedData !== null) {
                         $result['content'] = $cachedData->content;
                         $result['status'] = $cachedData->status;
                         ///Logger::Log('out>> '.$method.' '.$target, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
                         CacheManager::cacheData($sid, $com->getTargetName(), $target, $result['content'], $result['status'], $method);
                     } else {
                         $args = array('REQUEST_METHOD' => $method, 'PATH_INFO' => $add, 'slim.input' => $content);
                         if (isset($_SERVER['HTTP_SESSION'])) {
                             $args['HTTP_SESSION'] = $_SERVER['HTTP_SESSION'];
                         }
                         if (isset($_SERVER['HTTP_USER'])) {
                             $args['HTTP_USER'] = $_SERVER['HTTP_USER'];
                         }
                         if ($authbool) {
                             if (isset($_SESSION['UID'])) {
                                 $args['HTTP_USER'] = $_SESSION['UID'];
                                 $_SERVER['HTTP_USER'] = $_SESSION['UID'];
                             }
                             if (isset($_SESSION['SESSION'])) {
                                 $args['HTTP_SESSION'] = $_SESSION['SESSION'];
                                 $_SERVER['HTTP_SESSION'] = $_SESSION['SESSION'];
                             }
                             if ($sessiondelete) {
                                 if (isset($_SERVER['REQUEST_TIME'])) {
                                     $args['HTTP_DATE'] = $_SERVER['REQUEST_TIME'];
                                     $_SERVER['HTTP_DATE'] = $_SERVER['REQUEST_TIME'];
                                 }
                             } else {
                                 if (isset($_SESSION['LASTACTIVE'])) {
                                     $args['HTTP_DATE'] = $_SESSION['LASTACTIVE'];
                                     $_SERVER['HTTP_DATE'] = $_SESSION['LASTACTIVE'];
                                 }
                             }
                         }
                         if (isset($_SERVER['HTTP_DATE'])) {
                             $args['HTTP_DATE'] = $_SERVER['HTTP_DATE'];
                         }
                         $oldArgs = array('REQUEST_METHOD' => \Slim\Environment::getInstance()->offsetGet('REQUEST_METHOD'), 'PATH_INFO' => \Slim\Environment::getInstance()->offsetGet('PATH_INFO'), 'slim.input' => \Slim\Environment::getInstance()->offsetGet('slim.input'), 'HTTP_DATE' => \Slim\Environment::getInstance()->offsetGet('HTTP_DATE'), 'HTTP_USER' => \Slim\Environment::getInstance()->offsetGet('HTTP_USER'), 'HTTP_SESSION' => \Slim\Environment::getInstance()->offsetGet('HTTP_SESSION'), 'REQUEST_TIME' => \Slim\Environment::getInstance()->offsetGet('REQUEST_TIME'));
                         $oldRequestURI = $_SERVER['REQUEST_URI'];
                         $oldScriptName = $_SERVER['SCRIPT_NAME'];
                         ///$oldRedirectURL = $_SERVER['REDIRECT_URL'];
                         ///echo "old: ".$_SERVER['REQUEST_URI']."\n";
                         $_SERVER['REQUEST_URI'] = substr($target, strlen('http://localhost/') - 1);
                         //$tar.$add;
                         ///$_SERVER['REDIRECT_URL']= substr($target,strlen('http://localhost/')-1);
                         ///echo "mein: ".substr($target,strlen('http://localhost/')-1)."\n";
                         $_SERVER['SCRIPT_NAME'] = $h . '/' . $com->getLocalPath() . '/' . $com->getClassFile();
                         //$tar;
                         $_SERVER['QUERY_STRING'] = '';
                         $_SERVER['REQUEST_METHOD'] = $method;
//.........这里部分代码省略.........
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:Request.php

示例12: __toString

 /**
  * Return the the template as a string.
  *
  * Content is inserted into the template in this function
  */
 public function __toString()
 {
     // make the content available as if variables with the names of its
     // attributes had been declared
     $extractedCount = extract($this->content);
     if ($extractedCount != count($this->content)) {
         Logger::Log("Unable to extract all content.", LogLevel::WARNING);
     }
     // buffer the output
     ob_start();
     // evaluate the template as a php script
     // a closing php tag is needed before the template, so HTML can be
     // used in the template.
     $success = true;
     /*$success = eval("?>" . $this->template);*/
     include $this->templateFile;
     // stop buffering and return the buffer's content
     $s = ob_get_contents();
     ob_end_clean();
     if ($success === FALSE) {
         Logger::Log("Parse error in template: " . $this->template, LogLevel::WARNING);
     }
     return $s;
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:29,代码来源:Template.php

示例13: NuevaCaja

 /**
  *
  *Este metodo creara una caja asociada a una sucursal. Debe haber una caja por CPU. 
  *
  * @param token string el token que pos_client otorga por equipo
  * @param codigo_caja string El codigo de uso interno de la caja
  * @param impresoras json Un objeto con las impresoras asociadas a esta sucursal.
  * @param basculas json Un objeto con las basculas conectadas a esta caja.
  * @param descripcion string Descripcion de esta caja
  * @return id_caja int Id de la caja generada por la isnercion
  **/
 public static function NuevaCaja($token, $basculas = null, $control_billetes = 0, $descripcion = null, $id_sucursal = null, $impresoras = null)
 {
     Logger::log("Creando nueva caja");
     //Se validan los parametros de caja, si no se recibe sucursal, se intenta
     //tomar de la sesion
     $validar = self::validarParametrosCaja(null, $id_sucursal, $token, $descripcion);
     if (is_string($validar)) {
         Logger::error($validar);
         throw new Exception($validar);
     }
     if (is_null($id_sucursal)) {
         $id_sucursal = self::getSucursal();
         if (is_null($id_sucursal)) {
             Logger::error("No se pudo obtener la sucursal actual y no se obtuvo ninguna sucursal");
             throw new Exception("No se pudo obtener la sucursal actual y no se obtuvo ninguna sucursal");
         }
     }
     //si no recibimos control de billetes, lo ponemos en cero.
     if (is_null($control_billetes)) {
         $control_billetes = 0;
     }
     $caja = ContabilidadController::BuscarCuenta(1, $afectable = "", $clasificacion = "Activo Circulante", $clave = "", $consecutivo_en_nivel = "", $es_cuenta_mayor = "", $es_cuenta_orden = "", $id_cuenta_contable = "", $id_cuenta_padre = "", $naturaleza = "Deudora", $nivel = "", $nombre_cuenta = "Caja", $tipo_cuenta = "Balance");
     if (count($caja["resultados"]) < 1) {
         Logger::Log("Debe de existir la cuenta contable 'Caja' para dar de alta una caja");
         throw new BusinessLogicException("Debe de existir la cuenta contable 'Caja' para dar de alta una caja");
     }
     //se inserta la cuenta contable
     $res = ContabilidadController::NuevaCuenta($caja["resultados"][0]->getAbonosAumentan(), $caja["resultados"][0]->getCargosAumentan(), $caja["resultados"][0]->getClasificacion(), $caja["resultados"][0]->getEsCuentaMayor(), $caja["resultados"][0]->getEsCuentaOrden(), $caja["resultados"][0]->getIdCatalogoCuentas(), $caja["resultados"][0]->getNaturaleza(), $descripcion, $caja["resultados"][0]->getTipoCuenta(), $caja["resultados"][0]->getIdCuentaContable());
     //Se inicializa el registro de caja
     $caja = new Caja();
     $caja->setIdSucursal($id_sucursal);
     $caja->setAbierta(0);
     $caja->setActiva(1);
     $caja->setControlBilletes($control_billetes);
     $caja->setDescripcion($descripcion);
     $caja->setIdSucursal($id_sucursal);
     $caja->setSaldo(0);
     $caja->setToken($token);
     $caja->setIdCuentaContable($res["id_cuenta_contable"]);
     DAO::transBegin();
     try {
         //Se guarda el registro de caja y si se recibieron impresoras se registran con la caja
         //en la tabla impresora_caja.
         CajaDAO::save($caja);
         if (!is_null($impresoras)) {
             $impresoras = object_to_array($impresoras);
             if (!is_array($impresoras)) {
                 throw new Exception("Las impresoras son invalidas", 901);
             }
             $impresora_caja = new ImpresoraCaja(array("id_caja" => $caja->getIdCaja()));
             foreach ($impresoras as $id_impresora) {
                 if (is_null(ImpresoraDAO::getByPK($id_impresora))) {
                     throw new Exception("La impresora con id: " . $id_impresora . " no existe", 901);
                 }
                 $impresora_caja->setIdImpresora($id_impresora);
                 ImpresoraCajaDAO::save($impresora_caja);
             }
         }
     } catch (Exception $e) {
         DAO::transRollback();
         Logger::error("No se pudo crear la caja: " . $e);
         if ($e->getCode() == 901) {
             throw new Exception("No se pudo crear la caja: " . $e->getMessage(), 901);
         }
         throw new Exception("No se pudo crear la caja", 901);
     }
     DAO::transEnd();
     Logger::log("caja creada exitosamente");
     return array("id_caja" => $caja->getIdCaja());
 }
开发者ID:kailIII,项目名称:pos-erp,代码行数:81,代码来源:Sucursales.controller.php

示例14: can_see

 public static function can_see($persona_id, $owner_uid, $viewer_uid)
 {
     Logger::log("Enter: function PersonaHelper::can_see() persona_id: {$persona_id}, owner_uid; {$owner_uid}, viewer_uid: {$viewer_uid}");
     // load the persona to see it's privacy data
     try {
         $persona = new Persona();
         $persona->load($persona_id);
     } catch (PAException $e) {
         Logger::Log($e->getMessage());
         Logger::log("Exit: function PersonaHelper::can_see() with NULL");
         return null;
         // no persona!
     }
     $data = $persona->get_configuration_data();
     $perm = intval($data->perm);
     if ($viewer_uid == 0) {
         // anon users don't have relations
         $relation = 0;
         // and are definetly not family
         $in_family = 0;
     } else {
         if ($owner_uid == $viewer_uid) {
             $relation = 2;
             $in_family = 1;
         } else {
             // $relation = Relation::get_relation($owner_uid, $viewer_uid);
             $relations = Relation::get_relations($owner_uid);
             $relation = in_array($viewer_uid, $relations);
             $in_family = Relation::is_relation_in_family($owner_uid, $viewer_uid);
         }
     }
     Logger::log("PersonaHelper::can_see() perm: {$perm}, relation: {$relation}, in_family: {$in_family}");
     if (!$perm) {
         // permissions weren't set or are 0 == nobody
         Logger::log("Exit: function PersonaHelper::can_see() with NULL");
         return null;
     } else {
         if ($perm == 1) {
             // show to world (everybody)
             Logger::log("Exit: function PersonaHelper::can_see() with Persona");
             return $persona;
         } else {
             if ($perm == 2) {
                 // show to relations
                 if ($relation) {
                     Logger::log("Exit: function PersonaHelper::can_see() with Persona");
                     return $persona;
                 }
             } else {
                 if ($perm == 3) {
                     // show to family
                     if ($in_family) {
                         Logger::log("Exit: function PersonaHelper::can_see() with Persona");
                         return $persona;
                     }
                 } else {
                     Logger::log("Exit: function PersonaHelper::can_see() with NULL");
                     return null;
                 }
             }
         }
     }
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:63,代码来源:PersonaHelper.php

示例15: dirname

<?php

/**
 * @file index.php executes the DBUser component on calling via rest api
 *
 * @author Till Uhlig
 * @date 2014
 */
require_once dirname(__FILE__) . '/DBUser.php';
Logger::Log('begin DBUser', LogLevel::DEBUG);
new DBUser();
Logger::Log('end DBUser', LogLevel::DEBUG);
开发者ID:sawh,项目名称:ostepu-system,代码行数:12,代码来源:index.php


注:本文中的Logger::Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。