* @author Bart Visscher * @author Bernhard Posselt * @author Christoph Wurst * @author Joas Schilling * @author Julius Härtl * @author Morris Jobke * @author Olivier Paroz * @author Robin Appelman * @author Roeland Jago Douma * @author Thomas Müller * @author Victor Dubiniuk * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see * */ namespace OC; use OCP\Log\IDataLogger; use function array_merge; use InterfaSys\LogNormalizer\Normalizer; use OC\Log\ExceptionSerializer; use OCP\ILogger; use OCP\Log\IFileBased; use OCP\Log\IWriter; use OCP\Support\CrashReport\IRegistry; /** * logging utilities * * This is a stand in, this should be replaced by a Psr\Log\LoggerInterface * compatible logger. See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md * for the full interface specification. * * MonoLog is an example implementing this interface. */ class Log implements ILogger, IDataLogger { /** @var IWriter */ private $logger; /** @var SystemConfig */ private $config; /** @var boolean|null cache the result of the log condition check for the request */ private $logConditionSatisfied = null; /** @var Normalizer */ private $normalizer; /** @var IRegistry */ private $crashReporters; /** * @param IWriter $logger The logger that should be used * @param SystemConfig $config the system config object * @param Normalizer|null $normalizer * @param IRegistry|null $registry */ public function __construct(IWriter $logger, SystemConfig $config = null, $normalizer = null, IRegistry $registry = null) { // FIXME: Add this for backwards compatibility, should be fixed at some point probably if ($config === null) { $config = \OC::$server->getSystemConfig(); } $this->config = $config; $this->logger = $logger; if ($normalizer === null) { $this->normalizer = new Normalizer(); } else { $this->normalizer = $normalizer; } $this->crashReporters = $registry; } /** * System is unusable. * * @param string $message * @param array $context * @return void */ public function emergency(string $message, array $context = []) { $this->log(ILogger::FATAL, $message, $context); } /** * Action must be taken immediately. * * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * * @param string $message * @param array $context * @return void */ public function alert(string $message, array $context = []) { $this->log(ILogger::ERROR, $message, $context); } /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * * @param string $message * @param array $context * @return void */ public function critical(string $message, array $context = []) { $this->log(ILogger::ERROR, $message, $context); } /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * * @param string $message * @param array $context * @return void */ public function error(string $message, array $context = []) { $this->log(ILogger::ERROR, $message, $context); } /** * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * * @param string $message * @param array $context * @return void */ public function warning(string $message, array $context = []) { $this->log(ILogger::WARN, $message, $context); } /** * Normal but significant events. * * @param string $message * @param array $context * @return void */ public function notice(string $message, array $context = []) { $this->log(ILogger::INFO, $message, $context); } /** * Interesting events. * * Example: User logs in, SQL logs. * * @param string $message * @param array $context * @return void */ public function info(string $message, array $context = []) { $this->log(ILogger::INFO, $message, $context); } /** * Detailed debug information. * * @param string $message * @param array $context * @return void */ public function debug(string $message, array $context = []) { $this->log(ILogger::DEBUG, $message, $context); } /** * Logs with an arbitrary level. * * @param int $level * @param string $message * @param array $context * @return void */ public function log(int $level, string $message, array $context = []) { $minLevel = $this->getLogLevel($context); array_walk($context, [$this->normalizer, 'format']); $app = $context['app'] ?? 'no app in context'; // interpolate $message as defined in PSR-3 $replace = []; foreach ($context as $key => $val) { $replace['{' . $key . '}'] = $val; } $message = strtr($message, $replace); try { if ($level >= $minLevel) { $this->writeLog($app, $message, $level); if ($this->crashReporters !== null) { $messageContext = array_merge( $context, [ 'level' => $level ] ); $this->crashReporters->delegateMessage($message, $messageContext); } } else { if ($this->crashReporters !== null) { $this->crashReporters->delegateBreadcrumb($message, 'log', $context); } } } catch (\Throwable $e) { // make sure we dont hard crash if logging fails } } private function getLogLevel($context) { $logCondition = $this->config->getValue('log.condition', []); /** * check for a special log condition - this enables an increased log on * a per request/user base */ if ($this->logConditionSatisfied === null) { // default to false to just process this once per request $this->logConditionSatisfied = false; if (!empty($logCondition)) { // check for secret token in the request if (isset($logCondition['shared_secret'])) { $request = \OC::$server->getRequest(); if ($request->getMethod() === 'PUT' && strpos($request->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false && strpos($request->getHeader('Content-Type'), 'appli
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery UI Effects - removeClass Demo</title>
	<link rel="stylesheet" href="../../themes/base/all.css">
	<script src="../../external/jquery/jquery.js"></script>
	<script src="../../ui/effect.js"></script>
	<link rel="stylesheet" href="../demos.css">
	<style>
	.toggler { width: 500px; height: 200px; position: relative; }
	#button { padding: .5em 1em; text-decoration: none; }
	#effect { position: relative;  width: 240px;  padding: 1em;  letter-spacing: 0; font-size: 1.2em; border: 1px solid #000; background: #eee; color: #333; }
	.newClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; }
	</style>
	<script src="../../external/requirejs/require.js"></script>
	<script src="../bootstrap.js">
		$( "#button" ).on( "click", function() {
			$( "#effect" ).removeClass( "newClass", 1000, callback );
		});

		function callback() {
			setTimeout(function() {
				$( "#effect" ).addClass( "newClass" );
			}, 1500 );
		}
	</script>
</head>
<body>

<div class="toggler">
	<div id="effect" class="newClass ui-corner-all">
		Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede.
	</div>
</div>

<button id="button" class="ui-state-default ui-corner-all">Run Effect</button>

<div class="demo-description">
<p>Click the button above to preview the effect.</p>
</div>
</body>
</html>