本文整理汇总了PHP中Phalcon\Logger\Adapter\File::error方法的典型用法代码示例。如果您正苦于以下问题:PHP File::error方法的具体用法?PHP File::error怎么用?PHP File::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Logger\Adapter\File
的用法示例。
在下文中一共展示了File::error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleCardSubmitAction
/**
* Handle post data
*
* @return type
*/
public function handleCardSubmitAction()
{
$seri = $this->request->getPost('txtseri');
$sopin = $this->request->getPost('txtpin');
$mang = $this->request->getPost('chonmang');
$user = $this->request->getPost('txtuser');
$charid = $this->request->getPost('charguid');
$chargeDescription = $this->request->getPost('txtDescription');
if ($mang == 'MOBI') {
$ten = "Mobifone";
} else {
if ($mang == 'VIETEL') {
$ten = "Viettel";
} else {
if ($mang == 'GATE') {
$ten = "Gate";
} else {
if ($mang == 'VTC') {
$ten = "VTC";
} else {
$ten = "Vinaphone";
}
}
}
}
$arrayPost = array('merchant_id' => $this->config->baokim->merchant_id, 'api_username' => $this->config->baokim->api_username, 'api_password' => $this->config->baokim->api_password, 'transaction_id' => time(), 'card_id' => $mang, 'pin_field' => $sopin, 'seri_field' => $seri, 'algo_mode' => 'hmac');
// Prepare array post for CURL
ksort($arrayPost);
//mat khau di kem ma website dang kí trên B?o Kim
$secure_code = $this->config->baokim->secure_code;
$data_sign = hash_hmac('SHA1', implode('', $arrayPost), $secure_code);
$arrayPost['data_sign'] = $data_sign;
$userPwd = $this->config->baokim->CORE_API_HTTP_USR . ':' . $this->config->baokim->CORE_API_HTTP_PWD;
// Init curl
$curl = curl_init($this->config->baokim->restUrl);
curl_setopt_array($curl, array(CURLOPT_POST => true, CURLOPT_HEADER => false, CURLINFO_HEADER_OUT => true, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HTTPAUTH => CURLAUTH_DIGEST | CURLAUTH_BASIC, CURLOPT_USERPWD => $userPwd, CURLOPT_POSTFIELDS => http_build_query($arrayPost)));
$data = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$result = json_decode($data, true);
$logger = new FileAdapter($this->config->application->logFile);
// if ($status == 200) {
if ($status == 401) {
$logger->log("This is a message");
return $this->response->redirect('index/success');
} else {
$errorData = sprintf("Eror: %d | User: %s | Ma The: %s | Seri: %s", $status, $user, $seri, $sopin);
$logger->error($errorData);
return $this->response->redirect('index');
}
}
示例2: smtp
/**
* 邮件发送
* @param $toemail 收件人
* @param $subject 发件标题
* @param $email_message 发件内容
* <code>
* $mail = new \App\Plugin\Mail();
* $mail->smtp('2483175666@qq.com','Have a try','This is test content');
* </code>
*/
public function smtp($toemail, $subject, $email_message)
{
$email_from = '=?utf-8?B?' . base64_encode($this->sitename) . "?= <" . $this->mail_from . ">";
$email_subject = '=?utf-8?B?' . base64_encode(preg_replace("/[\r|\n]/", '', '[' . $this->sitename . '] ' . $subject)) . '?=';
$headers = "From: {$email_from} \r\nX-Priority: 3 \r\n X-Mailer: Chairsma \r\n MIME-Version: 1.0 \r\n Content-type: text/html\r\n charset=utf-8 \r\n Content-Transfer-Encoding: base64 \r\n ";
$log = new FileAdapter(LOGS_PATH . 'mail_' . date('Ymd') . '.log');
if (!($fp = pfsockopen($this->smtp_server, $this->smtp_port, $errno, $errstr, 30))) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ') CONNECT - Unable to connect to the SMTP server');
return false;
}
stream_set_blocking($fp, true);
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != '220') {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") CONNECT - {$lastmessage}");
return false;
}
fputs($fp, "HELO Charisma\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") Charisma - {$lastmessage}");
return false;
}
while (1) {
if (substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
break;
}
$lastmessage = fgets($fp, 512);
}
fputs($fp, "AUTH LOGIN\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 334) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") AUTH LOGIN - {$lastmessage}");
return false;
}
fputs($fp, base64_encode($this->mail_user) . "\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 334) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") USERNAME - {$lastmessage}");
return false;
}
fputs($fp, base64_encode($this->mail_password) . "\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 235) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") PASSWORD - {$lastmessage}");
return false;
}
fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") MAIL FROM - {$lastmessage}");
return false;
}
}
fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
$lastmessage = fgets($fp, 512);
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") RCPT TO - {$lastmessage}");
return false;
}
fputs($fp, "DATA\r\n");
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 354) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") DATA - {$lastmessage}");
return false;
}
fputs($fp, "Date: " . gmdate('r') . "\r\n");
$info = "\r\n发送时间:" . date('Y-m-d H:i:s') . "\r\n";
$info .= '发件人:' . $this->mail_from . "\r\n";
fputs($fp, "To: " . $toemail . "\r\n");
$info .= '收件人:' . $toemail . "\r\n";
fputs($fp, "Subject: " . $email_subject . "\r\n");
$info .= '标题:' . $subject . "\r\n";
fputs($fp, $headers);
fputs($fp, "\r\n\r\n");
fputs($fp, $email_message . "\r\n.\r\n");
$info .= '内容:' . $email_message . "\r\n";
$lastmessage = fgets($fp, 512);
if (substr($lastmessage, 0, 3) != 250) {
$log->error('(' . $this->smtp_server . ':' . $this->smtp_port . ") END - {$lastmessage}");
}
fputs($fp, "QUIT\r\n");
$log->log($info);
return true;
}
示例3: FactoryDefault
* Include composer autoloader
*/
require APP_PATH . "/vendor/autoload.php";
try {
/**
* The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
*/
$di = new FactoryDefault();
/**
* Include the application services
*/
require APP_PATH . "/app/config/services.php";
/**
* Handle the request
*/
$application = new Application($di);
echo $application->handle()->getContent();
} catch (Exception $e) {
/**
* Log the exception
*/
$logger = new Logger(APP_PATH . '/app/logs/error.log');
$logger->error($e->getMessage());
$logger->error($e->getTraceAsString());
/**
* Show an static error page
*/
$response = new Response();
$response->redirect('505.html');
$response->send();
}
示例4: saveAction
public function saveAction()
{
$this->view->title = "Збереження студента";
$errors = array();
!file_exists($this->logFileName) ? $attr = array('mode' => 'w') : ($attr = array());
$logger = new FileAdapter($this->logFileName, $attr);
$manager = new \Phalcon\Mvc\Model\Transaction\Manager();
$transaction = $manager->get();
$indCode = $this->request->get("ind_code");
if ($indCode != NULL) {
$logger->log("indCode not NULL");
if ($this->request->isPost()) {
$logger->log("POST request finded");
//debug($this->request->get());
if ($this->request->get("uid") == NULL) {
$user = new \Users();
$logger->log("new User created");
} else {
$user = \Users::findFirst($this->request->get("uid"));
if (!$user) {
$logger->warning("this User is not finded!");
$user = new \Users();
$logger->log("new User created");
} else {
$logger->log("User id is " . $user->id);
}
}
$user->setTransaction($transaction);
$logger->log("Transaction started");
$user->name = $this->request->get("name");
$user->last_name = $this->request->get("last_name");
$user->second_name = $this->request->get("second_name");
$user->login = $this->request->get("login");
$user->password = MD5($this->request->get("password"));
$user->is_male = $this->request->get("is_male");
$user->is_active = 1;
$user->email = $this->request->get("email");
$user->date_registration = date('Y-m-d H:i:s');
$user->birthday = $this->request->get("birthday");
$user->address_home = $this->request->get("address_home");
$user->phome = $this->request->get("phome");
$user->pmobile = $this->request->get("pmobile");
if ($this->request->get("id") == NULL) {
$student = new \Students();
$logger->log("new Student created");
} else {
$student = \Students::findFirst($this->request->get("id"));
if (!$student) {
$logger->warning("this Student is not finded!");
$student = new \Students();
$logger->log("new Student created");
} else {
$logger->log("Student id is " . $user->id);
}
}
//добавление студента
$student->ind_code = $indCode;
if (count($this->request->get("student_education")) > 0) {
$logger->log("student educations from request count>0, so start to add its");
$studentEducations = array();
//добавление образований
$c = 0;
foreach ($this->request->get("student_education") as $educ) {
$logger->log("Educ cycle #" . $c++);
$educJSON = json_decode($educ, true);
$se = new \StudentsEducation();
if (!array_key_exists("education_child_id", $educJSON)) {
$se->education_id = $educJSON["education_id"];
} else {
$se->education_id = $educJSON["education_child_id"];
}
$se->institution = $educJSON["institution"];
$se->speciality = $educJSON["speciality"];
$se->qualify = $educJSON["qualify"];
$se->diploma_number = $educJSON["diploma_number"];
$se->diploma_date = $educJSON["diploma_date"];
$logger->log("Educ id = " . $educJSON["education_id"]);
$studentEducations[] = $se;
}
} else {
$logger->warning("No educations in request!");
$studentEducations = NULL;
}
if ($student->StudentsEducation->count() > 0) {
$logger->warning("Finded old education(s) (" . $student->StudentsEducation->count() . ") in this Student. Trying to delete all its");
$c = 0;
foreach ($student->StudentsEducation as $se) {
$logger->log("Educ delation cycle #" . $c++);
$se->delete();
}
} else {
$logger->warning("no old educations finded!");
}
$student->StudentsEducation = $studentEducations;
//debug($student->StudentsEducation);
if (count($this->request->get("student_post")) > 0) {
$logger->log("There is Posts in request");
$studentPosts = array();
//добавление должностей
$logger->log("new Posts addition");
//.........这里部分代码省略.........
示例5: saveLoger
/**
* The function sending log for nginx or apache, it will to analytic later
* @return mixed
*/
public function saveLoger($e)
{
//error_log($e);
$logger = new Logger(ROOT_DIR . 'apps/logs/error.log');
if (is_object($e)) {
//d($e);
$logger->error($e[0]->getMessage());
}
if (is_array($e)) {
foreach ($e as $message) {
d($e);
}
}
if (is_string($e)) {
$logger->error($e);
}
return $this->indexRedirect();
}
示例6: basename
$modulesName[] = basename($path);
$module = $namespace . '\\Module';
$module = new $module();
}
$app = new Phalcon\Mvc\Micro();
$app->setDI($di);
/**
* Add exception handler to show them in json
*/
set_exception_handler(function ($e) use($app) {
$logger = new FileAdapter('debug.log');
$logger->warning($e->getMessage());
if (method_exists($e, 'send')) {
$e->send();
}
$logger->error($e->getTraceAsString());
});
/**
* Mount all collections (Makes routes active).
* @todo improve this block of code
*/
foreach ($modulesName as $module) {
$routeDefinitions = array('GET' => array(), 'POST' => array(), 'PUT' => array(), 'DELETE' => array());
try {
foreach ($di->get('collections_' . $module) as $collection) {
$app->mount($collection);
$routes = $app->getRouter()->getRoutes();
foreach ($routes as $route) {
$pattern = $route->getPattern();
$method = $route->getHttpMethods();
if (array_search($pattern, $routeDefinitions[$method]) !== false) {
示例7: testErrorLogging
/**
* Tests ERROR logging with error()
*
* @author Nikos Dimopoulos <nikos@phalconphp.com>
* @since 2012-09-17
*/
public function testErrorLogging()
{
$fileName = $this->getFileName('log', 'log');
$logger = new PhLoggerAdapterFile($this->logPath . $fileName);
$logger->error('Hello');
$logger->close();
$contents = file($this->logPath . $fileName);
$found = strpos($contents[0], '[ERROR]');
$this->assertTrue($found !== FALSE, 'Error logging is not set to ERROR');
$found = strpos($contents[0], 'Hello');
$this->assertTrue($found !== FALSE, 'Error logging does not set correct message');
$this->cleanFile($this->logPath, $fileName);
}
示例8: error
public function error($msg)
{
$this->logger->error($msg);
}
示例9: saveLoger
/**
* Tracking logs to a files
*
* @return bool
*/
public function saveLoger($e)
{
$logger = new Logger(ROOT_DIR . 'content/logs/error.log');
if (is_object($e)) {
$logger->error($e[0]->getMessages());
$logger->error($e[0]->getTraceAsString());
}
if (is_array($e)) {
foreach ($e as $message) {
$logger->error($message->getMessage());
}
}
if (is_string($e)) {
$logger->error($e);
}
return false;
}
示例10: FileAdapter
<?php
use Phalcon\Logger\Adapter\File as FileAdapter;
$logger = new FileAdapter("app/logs/test.log");
$logger->log("This is a message");
$logger->log("This is an error", \Phalcon\Logger::ERROR);
$logger->error("This is another error");