本文整理汇总了PHP中Logger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::log方法的具体用法?PHP Logger::log怎么用?PHP Logger::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Sets up the niftyException object
*
* @param string $message
* @param mixed $code
* @param Exception $previous
*/
public function __construct($message, $code = 0, Exception $previous = null)
{
$this->priorException = $previous;
parent::__construct($message, $code);
$this->logger = new logger();
$this->logger->log($this);
}
示例2: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param mixed $message
* @param mixed[] $context
* @return null
*/
public function log($level, $message, array $context = array())
{
if (!array_key_exists($level, $this->levels)) {
$level = $this->defaultLevel;
}
$level = \LoggerLevel::toLevel($this->levels[$level], $this->defaultLevel);
$message = $this->formatter->format($level, $message, $context);
$this->logger->log($level, $message);
}
示例3: testCreation
/**
* Function to test the storage of logs in mail.
*/
public function testCreation()
{
$this->markTestSkipped('Mailing log results currently cannot be tested automatically.');
$myLogger = new Logger(__DIR__ . "/../../../libs/logs/media/default_mail_config.php");
//create a handler to store the logs. Provide that logger with a configuration file.
$myLogger->log("This is the first message", "WARNING", "LOW");
//store this log.
$myLogger->log("This is the second message");
//store this log.
//You should see two mails in your mailbox.
}
示例4: testCreation
/**
* Function to test the storage of logs in SYSLOG.
*/
public function testCreation()
{
$myLogger = new Logger(__DIR__ . "/../../../libs/logs/media/default_syslog_config.php");
//create a handler to store the logs. Provide that logger with a configuration file.
$myLogger->log("This is the first message", "WARNING", "LOW");
//store this log.
$myLogger->log("This is the second message");
//store this log.
//You can see the results in the console.
//You can also check using this command in your shell:
//grep -R "This is the first message" /var/log
//You should see entries containing message "This is the first message"
}
示例5: testCreation
/**
* Function to test the storage of logs in file.
*/
public function testCreation()
{
$myLogger = new Logger(__DIR__ . "/testFileConfig.php");
//create a handler to store the logs. Provide that logger with a configuration file.
$myLogger->log("This is the first message", "WARNING", "LOW");
//store this log.
$myLogger->log("This is the second message");
//store this log.
if (file_exists("myfile.php")) {
$this->assertTrue(TRUE);
} else {
$this->assertTrue(FALSE);
}
}
示例6: log
/**
* Logs a message.
*
* @param $sMessage @type string The message.
*/
public function log($sMessage)
{
$level = 'info';
$message = $sMessage;
$matches = [];
preg_match('/^(\\w+):\\s*(.*)$/', $sMessage, $matches);
if (count($matches) == 3) {
$act = strtolower($matches[1]);
$message = $matches[2];
if ($act != 'status') {
$level = $act;
}
}
$this->monolog->log($level, $message);
}
示例7: log
/**
* Logs message or exception to file (if not disabled) and sends email notification (if enabled).
* @param string|Exception
* @param int one of constant Debugger::INFO, WARNING, ERROR (sends email), CRITICAL (sends email)
* @return string logged error filename
*/
public static function log($message, $priority = self::INFO)
{
if (self::$logDirectory === FALSE) {
return;
} elseif (!self::$logDirectory) {
throw new InvalidStateException('Logging directory is not specified in Debugger::$logDirectory.');
}
if ($message instanceof Exception) {
$exception = $message;
$message = ($message instanceof FatalErrorException ? 'Fatal error: ' . $exception->getMessage() : get_class($exception) . ": " . $exception->getMessage()) . " in " . $exception->getFile() . ":" . $exception->getLine();
$hash = md5($exception . (method_exists($exception, 'getPrevious') ? $exception->getPrevious() : (isset($exception->previous) ? $exception->previous : '')));
$exceptionFilename = "exception-" . @date('Y-m-d-H-i-s') . "-{$hash}.html";
foreach (new DirectoryIterator(self::$logDirectory) as $entry) {
if (strpos($entry, $hash)) {
$exceptionFilename = $entry;
$saved = TRUE;
break;
}
}
}
self::$logger->log(array(@date('[Y-m-d H-i-s]'), trim($message), self::$source ? ' @ ' . self::$source : NULL, !empty($exceptionFilename) ? ' @@ ' . $exceptionFilename : NULL), $priority);
if (!empty($exceptionFilename)) {
$exceptionFilename = self::$logDirectory . '/' . $exceptionFilename;
if (empty($saved) && ($logHandle = @fopen($exceptionFilename, 'w'))) {
ob_start();
// double buffer prevents sending HTTP headers in some PHP
ob_start(create_function('$buffer', 'extract(NCFix::$vars[' . NCFix::uses(array('logHandle' => $logHandle)) . '], EXTR_REFS); fwrite($logHandle, $buffer); '), 4096);
self::$blueScreen->render($exception);
ob_end_flush();
ob_end_clean();
fclose($logHandle);
}
return strtr($exceptionFilename, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
}
}
示例8: parse_cookie
public function parse_cookie($cookie)
{
// Parse the given cookie
if (!preg_match("/^uid:(\\d+):([a-z0-9]+):([a-z0-9]+)\$/", $cookie, $m)) {
Logger::log("Invalid login cookie received: {$cookie}", LOGGER_WARNING);
// Invalid cookie - ignore it
return FALSE;
}
list(, $this->user_id, $this->series, $this->token) = $m;
$this->user_id = (int) $this->user_id;
// Flush old cookies
Dal::query("DELETE FROM login_cookies WHERE expires < NOW()");
// Locate our cookie
$r = Dal::query_one("SELECT token FROM login_cookies WHERE user_id=? AND series=?", array($this->user_id, $this->series));
if (!$r) {
// Totally invalid - we don't even know of the series. Probably timed out.
return FALSE;
}
list($token) = $r;
if ($token != $this->token) {
// Possible attack detected - invalidate all sessions for this user
Dal::query("DELETE FROM login_cookies WHERE user_id=?", array($this->user_id));
Logger::log("Invalidated all sessions for user {$this->user_id} as a valid series ID but invalid token was presented -- someone has possibly had their login cookie stolen!", LOGGER_WARNING);
return FALSE;
}
// Success -- assign a new token
$this->token = $this->make_token();
Dal::query("UPDATE login_cookies SET token=?, expires=DATE_ADD(NOW(), INTERVAL " . LoginCookie::$cookie_lifetime . " SECOND) WHERE user_id=? AND series=?", array($this->token, $this->user_id, $this->series));
return $this->user_id;
}
示例9: convertdata
private function convertdata($data)
{
$this->data = null;
if (is_null($data)) {
return;
} else {
$this->copyValueToKey($data);
// first copys in all the data that has one to one relation
foreach ($this->propertyTable as $key => &$obj) {
//then copy the logical properties over
$value = null;
$datafieldname = $this->getDatafieldname($key);
if (is_null($datafieldname) == false) {
$value = $data->{$datafieldname};
}
if ($obj->logicdefined == true) {
if ($key == 'boek') {
$book = new boek(null);
$booktoget = intval($data->boekid);
$book->retrieveByID($booktoget);
$this->data->{$key} = $book;
// $this->valtodata($key,false);
} else {
$msg = 'objectfield \'' . $key . '\' should be logicdefined while no definition in objectDef ' . '<br/>';
Logger::log($msg);
die;
}
}
}
unset($obj);
}
}
示例10: UpdateManager
function UpdateManager($continue)
{
if ($continue == "false") {
Logger::log(__FUNCTION__, "Skipping update check. Change SMARTSOCKET_AUTOUPDATE to true on Config.xml");
return false;
} else {
Logger::log(__FUNCTION__, "Checking for updates...");
if ($latest = @(int) file_get_contents("http://smartsocket.googlecode.com/svn/trunk/DIST/BUILD")) {
//# Compare build number
if (SMARTSOCKET_BUILD < $latest) {
Logger::log(__FUNCTION__, "Update found...");
if ($file = @file_get_contents("http://smartsocket.googlecode.com/svn/trunk/DIST/libsmartsocket.dll", FILE_BINARY)) {
Logger::log(__FUNCTION__, "Update retrieved...");
$update = fopen("libsmartsocket.dll", "wb");
fwrite($update, $file);
fclose($update);
Logger::log(__FUNCTION__, "Update applied.");
Logger::log(__FUNCTION__, "To see the changes, check out http://www.smartsocket.net");
Logger::log(__FUNCTION__, "You must now restart SmartSocket.", true);
} else {
Logger::log(__FUNCTION__, "Could not reach the latest stable build file.");
}
} elseif (SMARTSOCKET_BUILD > $latest) {
Logger::log(__FUNCTION__, "Your build (" . SMARTSOCKET_BUILD . ") is newer than the public release ({$latest}).");
} else {
Logger::log(__FUNCTION__, "You already have the latest build.");
}
} else {
Logger::log(__FUNCTION__, "Could not reach the latest stable build report.");
}
}
}
示例11: rebuild
public function rebuild($start_date = null, $end_date = null)
{
if (!$start_date) {
$start_date = config_option('last_sharing_table_rebuild');
}
if ($start_date instanceof DateTimeValue) {
$start_date = $start_date->toMySQL();
}
if ($end_date instanceof DateTimeValue) {
$end_date = $end_date->toMySQL();
}
if ($end_date) {
$end_cond = "AND updated_on <= '{$end_date}'";
}
try {
$object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
$obj_count = 0;
DB::beginWork();
foreach ($object_ids as $id) {
$obj = Objects::findObject($id);
if ($obj instanceof ContentDataObject) {
$obj->addToSharingTable();
$obj_count++;
}
}
set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
DB::commit();
} catch (Exception $e) {
DB::rollback();
Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
}
return $obj_count;
}
示例12: saveAction
public function saveAction()
{
try {
if ($this->getParam("id")) {
$link = Document\Hardlink::getById($this->getParam("id"));
$this->setValuesToDocument($link);
$link->setModificationDate(time());
$link->setUserModification($this->getUser()->getId());
if ($this->getParam("task") == "unpublish") {
$link->setPublished(false);
}
if ($this->getParam("task") == "publish") {
$link->setPublished(true);
}
// only save when publish or unpublish
if ($this->getParam("task") == "publish" && $link->isAllowed("publish") || $this->getParam("task") == "unpublish" && $link->isAllowed("unpublish")) {
$link->save();
$this->_helper->json(["success" => true]);
}
}
} catch (\Exception $e) {
\Logger::log($e);
if (\Pimcore\Tool\Admin::isExtJS6() && $e instanceof Element\ValidationException) {
$this->_helper->json(["success" => false, "type" => "ValidationException", "message" => $e->getMessage(), "stack" => $e->getTraceAsString(), "code" => $e->getCode()]);
}
throw $e;
}
$this->_helper->json(false);
}
示例13: logCreation
public static function logCreation($path, $isDir)
{
$message = $_SERVER['REMOTE_ADDR'] . " " . GateKeeper::getUserName() . " created ";
$message .= $isDir ? "dir" : "file";
$message .= " " . $path;
Logger::log($message);
}
示例14: http
function http($method = "GET", $url, $argArray = null)
{
require_once "HTTP/Client.php";
$agent = new HTTP_Client();
if ($method == "POST") {
$code = $agent->post($url, $argArray);
} else {
if ($argArray) {
// build query string from $argArray
if (strpos("?", $url)) {
$query = "&";
} else {
$query = "?";
}
$url .= $query . http_build_query($argArray);
}
$code = $agent->get($url);
}
if (PEAR::isError($code)) {
$error = $code->getMessage();
Logger::log(basename(__FILE__) . " {$method} {$url} failed: {$error}");
return false;
} else {
$responseArray = $agent->currentResponse();
return $responseArray['body'];
}
}
示例15: add_user_play
public static function add_user_play($username, $password, $artist, $album, $title, $length)
{
// ensure we have the length in milliseconds.
$length = Format::fix_length($length);
if ($length === -1) {
Logger::log("add_play: failed to convert length to milliseconds");
return false;
}
// unknown artist/album ("") becomes "N/A"
if ($artist === "") {
$artist = "N/A";
}
if ($album === "") {
$album = "N/A";
}
$db = Database::instance();
$sql = 'SELECT api_add_user_play(?, ?, ?, ?, ?, ?) AS success';
$params = array($username, $password, $artist, $album, $title, $length);
try {
$rows = $db->select($sql, $params);
} catch (Exception $e) {
Logger::log("add_user_play: database failure: " . $e->getMessage());
return false;
}
return count($rows) === 1 && $rows[0]['success'] === true;
}