本文整理汇总了PHP中Cake\Log\Log::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::write方法的具体用法?PHP Log::write怎么用?PHP Log::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Log\Log
的用法示例。
在下文中一共展示了Log::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
public static function write($type, $message, $params = [], $trace_level = 0, $log_options = [])
{
$trace_level += 1;
$trace = self::traceMessage($trace_level);
$output = call_user_func_array('sprintf', array_merge([$message], $params));
CakeLog::write($type, $trace . ' - ' . $output, $log_options);
}
示例2: auth
/**
* Auth method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function auth()
{
//ログイン処理
// パラメータの受取
$name = $this->request->data['userId'];
$pass = $this->request->data['pass'];
//Usersテーブルを検索
$tableUsers = TableRegistry::get('Users');
$queryStr = "select name from users where name='" . $name . "' and password = '" . $pass . "'";
// パスワード入力値 or 1=1;--
//$queryStr = "select name from users where name='" . $name . "' and password = '" . $pass . "' or 1=1";
Log::write('debug', $queryStr);
//SQL発行
$data = $tableUsers->connection()->query($queryStr);
//配列のサイズで判定する
$cnt = sizeof($data);
if ($cnt == 0) {
//レコードなし認証NGとする
Log::write('debug', '認証エラー');
$this->Flash->error('Auth Error: id or password is incorrect');
// ログイン画面に戻る
return $this->redirect(['action' => '../Login/index']);
}
Log::write('debug', '認証OK');
foreach ($data as $key => $value) {
Log::write('debug', 'userName is :' . $value['name']);
$this->request->session()->write('loginUser', $value['name']);
}
// 成功した場合は記事一覧へ
return $this->redirect(['action' => '../Articles/index']);
}
示例3: fetchStudentOrganizations
/**
* @author team_syzzygy
* @param Connection $dbConnection
* @param unknown $studentId
* Fetch student organizations based on the studentId provided
*/
public function fetchStudentOrganizations(Connection $dbConnection, $studentId)
{
$studentTable = $this->getStudentReference();
Log::write('debug', "Student Id passed into fetchStudentOrganizations method is " . $studentId);
$temp = $studentTable->find()->where(['Student_ID' => $studentId])->contain(['StudentOrganizationTypeT'])->first();
return $temp;
}
示例4: testSummary
/**
* Test that the log panel outputs a summary.
*
* @return void
*/
public function testSummary()
{
Log::write('error', 'Test');
$this->assertEquals(1, $this->panel->summary());
Log::write('error', 'Test 2');
Log::write('notice', 'A thing');
$this->assertEquals(3, $this->panel->summary());
}
示例5: toArray
/**
*
* @return array Um array com os dados da resposta.
*/
public function toArray()
{
if (is_null($this->_response->json)) {
Log::write('debug', print_r($this->_response->body));
return ['success' => false, 'message' => 'Erro na resposta recebida do servidor.'];
}
return $this->_response->json;
}
示例6: main
public function main()
{
$XTime = time() - 60 * 24 * 3600;
$conditions = array('Notifications.created <' => date('Y-m-d H:i:s', $XTime));
if (!$this->Notifications->deleteAll($conditions)) {
Log::write('error', 'FAILED: Deleting older Notifications!!', 'cron_jobs');
}
}
示例7: initialize
public function initialize()
{
$loginUser = $this->request->session()->read('loginUser');
Log::write('debug', 'article:' . $loginUser);
if (empty($loginUser)) {
Log::write('debug', '未ログインエラー');
return $this->redirect(['action' => '../Error/index']);
}
}
示例8: search
public function search()
{
if ($this->request->is('ajax')) {
Log::write('debug', 'Dies ist ein Test');
$isbn = $this->request->query['value'];
echo json_encode(Dnb::dnb($isbn));
die;
}
}
示例9: testLogging
/**
* testLogging
*
* @return void
*/
public function testLogging()
{
Log::config('dblogtest', ['className' => 'Burzum\\DatabaseLog\\Log\\Engine\\DatabaseLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency']]);
Log::write('warning', 'testing');
$result = $this->Logs->find()->first();
$this->assertEquals($result->level, 'warning');
$this->assertEquals($result->message, 'testing');
$this->Logs->deleteAll([]);
}
示例10: afterRules
public function afterRules(Cake\Event\Event $event, Cat $entity, \ArrayObject $options, $result, $operation)
{
Log::write("debug", "afterRules");
Log::write("debug", $event->name());
Log::write("debug", "entity " . $entity);
Log::write("debug", $options);
Log::write("debug", "result " . $result);
Log::write("debug", "operation " . $operation);
}
示例11: send
public function send(Email $email)
{
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
$to = $headers['To'];
$subject = str_replace(["\r", "\n"], '', $email->subject());
$to = str_replace(["\r", "\n"], '', $to);
$message = implode('\\n', $email->message());
Log::write('debug', 'Mail: to(' . $to . ') subject(' . $subject . ') message(' . $message . ')');
return ['headers' => $headers, 'message' => $message];
}
示例12: testReset
/**
* @return void
*/
public function testReset()
{
$this->Logs = TableRegistry::get('DatabaseLog.DatabaseLogs');
Log::write('info', 'six');
$count = $this->Logs->find()->count();
$this->assertTrue($count > 0);
$this->Shell->runCommand(['reset', '-q']);
$count = $this->Logs->find()->count();
$this->assertSame(0, $count);
}
示例13: testLogWriting
/**
* Tests the log write method
*
* @return void
*/
public function testLogWriting()
{
$View = new View();
$countBefore = $this->Logs->find()->count();
$View->log('x');
$View->log('warning', LOG_WARNING);
Log::write(LOG_ERR, 'y');
Log::write(LOG_INFO, 'z');
$countAfter = $this->Logs->find()->count();
$this->assertSame($countBefore + 8, $countAfter);
// should be 4 (but for some reason everything is added twice
}
示例14: _logException
/**
* Handles exception logging
*
* @param \Exception $exception Exception instance.
* @return bool
*/
protected function _logException(\Exception $exception)
{
$blacklist = ['Cake\\Routing\\Exception\\MissingControllerException', 'Cake\\Routing\\Exception\\MissingActionException', 'Cake\\Routing\\Exception\\PrivateActionException', 'Cake\\Routing\\Exception\\NotFoundException'];
if (isset($this->_options['log404'])) {
$blacklist = $this->_options['log404'];
}
if ($blacklist && in_array(get_class($exception), (array) $blacklist)) {
$level = LOG_ERR;
Log::write($level, $this->_getMessage($exception), ['404']);
return;
}
return parent::_logException($exception);
}
示例15: _logException
/**
* Handles exception logging
*
* @param \Exception $exception Exception instance.
* @return bool
*/
protected function _logException(Exception $exception)
{
$blacklist = ['Cake\\Routing\\Exception\\MissingControllerException', 'Cake\\Routing\\Exception\\MissingActionException', 'Cake\\Routing\\Exception\\PrivateActionException', 'Cake\\Routing\\Exception\\NotFoundException', 'Cake\\Datasource\\Exception\\RecordNotFoundException', 'Cake\\Network\\Exception\\MethodNotAllowedException', 'Cake\\Network\\Exception\\BadRequestException', 'Cake\\Network\\Exception\\ForbiddenException', 'Cake\\Network\\Exception\\GoneException', 'Cake\\Network\\Exception\\ConflictException', 'Cake\\Network\\Exception\\InvalidCsrfToken', 'Cake\\Network\\Exception\\UnauthorizedException', 'Cake\\Network\\Exception\\NotAcceptableException'];
if (isset($this->_options['log404'])) {
$blacklist = $this->_options['log404'];
}
if ($blacklist && in_array(get_class($exception), (array) $blacklist)) {
$level = LOG_ERR;
Log::write($level, $this->_getMessage($exception), ['404']);
return false;
}
return parent::_logException($exception);
}