本文整理汇总了PHP中Log::logMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::logMessage方法的具体用法?PHP Log::logMessage怎么用?PHP Log::logMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::logMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userCheck
function userCheck($username, $password)
{
$log = new Log("log");
$array = fileOpen();
print_r($array);
$true = false;
$_SESSION['is-logged-in'] = $true;
for ($i = 0; $i < count($array); $i++) {
if (Auth::attempt($username, $password, $array[$i]["password"])) {
$true = true;
$log->logMessage("SWEET", "That password for {$username} was correct!, Logging {$username} in!");
$sessionuname = $array[$i]["username"];
$_SESSION["username"] = $sessionuname;
break;
} else {
$true = false;
$log->logMessage("HEY!", "That password for {$username} was incorrect!");
$sessionuname = "Guest";
$_SESSION["username"] = $sessionuname;
}
}
if ($true == true) {
return "You did it {$sessionuname}!";
} else {
return "You didn't say the magic word!";
}
}
示例2: logStripeException
private function logStripeException($exception, $identifier)
{
$response = $exception->getJsonBody();
// Log the Error
$log = new Log(STRIPE_LOG);
$log->setFatal(true);
$log->logMessage(sprintf("Stripe Exception (%s) [%s]: %s (identifier: %s), HTTP Status: %d", get_class($exception), $response['error']['type'], $response['error']['message'], $identifier, $exception->getHttpStatus()));
// Show a Friendly Error Page
$view = new HTMLView();
$view->includeTemplate('error.fatal', ['app_name' => AppConfig::getValue('app_name')]);
$view->render(true);
exit;
// die now!
}
示例3: send
public function send()
{
// Don't send in development...
if (isTrue(AppConfig::getValue('development'))) {
(new Log(INFO_LOG))->logMessage('email (' . $this->mailer->Subject . ') sent to ' . (count($this->mailer->getToAddresses()) > 1 ? print_r($this->mailer->getToAddresses(), true) : $this->mailer->getToAddresses()[0][0]) . ', body: ' . $this->mailer->Body);
return true;
}
// Test the Outcome (log errors)
if (($status = $this->mailer->send()) === false) {
$log = new Log(ERROR_LOG);
$log->logMessage(__METHOD__ . ' failed, ' . $this->mailer->ErrorInfo);
return false;
} else {
(new Log(INFO_LOG))->logMessage('email (' . $this->mailer->Subject . ') sent to ' . (count($this->mailer->getToAddresses()) > 1 ? print_r($this->mailer->getToAddresses(), true) : $this->mailer->getToAddresses()[0][0]) . ', body: ' . $this->mailer->Body);
return true;
}
}
示例4: validateToken
public function validateToken($token)
{
// Can't protect when on localhost, so turn off...
if (COOKIE_DOMAIN === 'localhost') {
return true;
}
if (self::isValidToken($token) && $token === $this->cookie_token) {
return true;
// token is valid
} else {
// Log the Error
$log = new Log(SECURITY_LOG);
$log->logMessage("Possible CSRF attack detected, warning the user...");
// Display a Warning
$this->displayWarning();
}
}
示例5: Log
<?php
require_once 'Log.php';
$log = new Log('cli');
$log->info("This is an info level message");
$log->error("This is an error!");
$log->logMessage("WARNING", "This is a warning message.");
示例6: Log
<?php
require_once "Log.php";
$log = new Log();
$log->filename = 'log-' . date('Y-m-d') . '.log';
$log->info('User logged in successfully');
$log->error('You do not have permission to view this file');
$log->logMessage('error', '404 page not found');
示例7: Log
<?php
require_once 'log.php';
$logger = new Log();
// $logger is an object (instance) of the class log
$logger->logMessage("info", "Today is");
// the object $logger is calling a method, which is defined in the class Log
$logger->logMessage("error", "Try again");
示例8: __construct
<?php
class Log
{
public $handle;
public $filename;
public function __construct($prefix = 'log')
{
// Set the $filename property of the class to $prefix-YYYY-MM-DD.log.
$this->filename = $prefix . date('Y-m-d') . '.log';
//Open the $filename for appending and assign the file pointer to the property $handle.
$this->handle = fopen($this->filename, 'a');
}
public function logMessage($logLevel, $message)
{
$stringToWrite = PHP_EOL . "[{$logLevel}] {$message}";
fwrite($this->handle, $stringToWrite);
}
public function __destruct()
{
fclose($this->handle);
}
}
// procedural code
$log = new Log();
$log->logMessage('INFO', 'this info message is working');
unset($log);
示例9: header
require_once 'Log.php';
$correctName = Input::get('username', '');
$correctPassword = Input::get('password', '');
if (Auth::check()) {
header('Location: /php/authorize.php');
die;
} else {
if (Auth::attempt($correctName, $correctPassword)) {
$logFile = new Log();
$logFile->logMessage('loggedIN', 'user has logged in successfully');
header('Location: /php/authorize.php');
die;
} else {
if (input::has('username') && input::has('password')) {
$logFile = new Log();
$logFile->logMessage('Failed', 'user failed to input correct username or password');
echo "Please enter the correct username or password.";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/">
<meta charset="utf-8">
<title></title>
</head>
<body>
<form method="post">
<label for="username">Username</label>
示例10: Log
<?php
require_once "../log.php";
$log = new Log(07734);
$log->logMessage("HELLO", "I hope this works!");
$log->logInfo();
示例11: Log
<?php
require_once 'Log.php';
$log = new Log();
// $log->filename = 'log-YYYY-MM-DD.log';
$log->logMessage('error', 'There was an error') . PHP_EOL;
$log->info('Awesome, done successfully ' . PHP_EOL);
$log->error('You do not have permission to view this ' . PHP_EOL);
示例12: Log
<?php
require_once "Log.php";
$logFile = new Log();
$logFile->logMessage('info', 'This is some info');
示例13: Log
<?php
require_once "log.php";
$log = new Log();
$log->logInfo('User logged in successfutlly');
$log->logError('You do not have permission to view this file');
$log->logMessage('ERROR', '404 page not found');
示例14: Log
<?php
// Update log_test.php; pass the prefix 'cli' to the class and do not manually set the $filename property. Test from the command line.
// At the top of log_test.php, be sure to require_once 'Log.php';
require_once 'Log.php';
// Create an instance of the Log class
$logTest = new Log('cli');
// Set the $filename property in the class; use the format log-YYYY-MM-DD.log.
// $logTest->filename = "log-".date('Y-m-d').".log";
// Call the methods logMessage(), info(), and error() with to test the functionality of each.
$logTest->logMessage("INFO", "This message called by logMessage().");
$logTest->info("This message called by info().");
$logTest->error("This message called by error().");
// Use log_test.php to test your class by calling it from the command line.