Use internally \OCP\ILogger instead of \OC\Log

* this is the preparation for some upcoming logger related changes
* also fixes an issue in the public interface where we request
  an internal class as parameter
This commit is contained in:
Morris Jobke 2015-04-30 11:52:30 +02:00
parent ae853445ef
commit fbba7a61cb
8 changed files with 24 additions and 17 deletions

View File

@ -354,7 +354,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$sorter = new \OC\Share\SearchResultSorter((string)$_GET['search'], $sorter = new \OC\Share\SearchResultSorter((string)$_GET['search'],
'label', 'label',
new \OC\Log()); \OC::$server->getLogger());
usort($shareWith, array($sorter, 'sort')); usort($shareWith, array($sorter, 'sort'));
OC_JSON::success(array('data' => $shareWith)); OC_JSON::success(array('data' => $shareWith));
} }

View File

@ -24,6 +24,7 @@
namespace OC\BackgroundJob; namespace OC\BackgroundJob;
use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJob;
use OCP\ILogger;
abstract class Job implements IJob { abstract class Job implements IJob {
/** /**
@ -43,9 +44,9 @@ abstract class Job implements IJob {
/** /**
* @param JobList $jobList * @param JobList $jobList
* @param \OC\Log $logger * @param ILogger $logger
*/ */
public function execute($jobList, $logger = null) { public function execute($jobList, ILogger $logger = null) {
$jobList->setLastRun($this); $jobList->setLastRun($this);
try { try {
$this->run($this->argument); $this->run($this->argument);

View File

@ -21,6 +21,7 @@
*/ */
namespace OC\BackgroundJob; namespace OC\BackgroundJob;
use OCP\ILogger;
/** /**
* Class QueuedJob * Class QueuedJob
@ -34,9 +35,9 @@ abstract class QueuedJob extends Job {
* run the job, then remove it from the joblist * run the job, then remove it from the joblist
* *
* @param JobList $jobList * @param JobList $jobList
* @param \OC\Log $logger * @param ILogger $logger
*/ */
public function execute($jobList, $logger = null) { public function execute($jobList, ILogger $logger = null) {
$jobList->remove($this, $this->argument); $jobList->remove($this, $this->argument);
parent::execute($jobList, $logger); parent::execute($jobList, $logger);
} }

View File

@ -21,6 +21,7 @@
*/ */
namespace OC\BackgroundJob; namespace OC\BackgroundJob;
use OCP\ILogger;
/** /**
* Class QueuedJob * Class QueuedJob
@ -45,9 +46,9 @@ abstract class TimedJob extends Job {
* run the job if * run the job if
* *
* @param JobList $jobList * @param JobList $jobList
* @param \OC\Log $logger * @param ILogger $logger
*/ */
public function execute($jobList, $logger = null) { public function execute($jobList, ILogger $logger = null) {
if ((time() - $this->lastRun) > $this->interval) { if ((time() - $this->lastRun) > $this->interval) {
parent::execute($jobList, $logger); parent::execute($jobList, $logger);
} }

View File

@ -23,10 +23,10 @@
namespace OC\Log; namespace OC\Log;
use OC\Log as LoggerInterface; use OCP\ILogger;
class ErrorHandler { class ErrorHandler {
/** @var LoggerInterface */ /** @var ILogger */
private static $logger; private static $logger;
/** /**
@ -50,7 +50,7 @@ class ErrorHandler {
set_exception_handler(array($handler, 'onException')); set_exception_handler(array($handler, 'onException'));
} }
public static function setLogger(LoggerInterface $logger) { public static function setLogger(ILogger $logger) {
self::$logger = $logger; self::$logger = $logger;
} }

View File

@ -23,6 +23,8 @@
*/ */
namespace OC\Share; namespace OC\Share;
use OCP\ILogger;
class SearchResultSorter { class SearchResultSorter {
private $search; private $search;
private $encoding; private $encoding;
@ -34,9 +36,9 @@ class SearchResultSorter {
* @param string $key the array key containing the value that should be compared * @param string $key the array key containing the value that should be compared
* against * against
* @param string $encoding optional, encoding to use, defaults to UTF-8 * @param string $encoding optional, encoding to use, defaults to UTF-8
* @param \OC\Log $log optional * @param ILogger $log optional
*/ */
public function __construct($search, $key, \OC\Log $log = null, $encoding = 'UTF-8') { public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
$this->encoding = $encoding; $this->encoding = $encoding;
$this->key = $key; $this->key = $key;
$this->log = $log; $this->log = $log;

View File

@ -37,6 +37,7 @@ use OC_Installer;
use OC_Util; use OC_Util;
use OCP\IConfig; use OCP\IConfig;
use OC\Setup; use OC\Setup;
use OCP\ILogger;
/** /**
* Class that handles autoupdating of ownCloud * Class that handles autoupdating of ownCloud
@ -49,7 +50,7 @@ use OC\Setup;
*/ */
class Updater extends BasicEmitter { class Updater extends BasicEmitter {
/** @var \OC\Log $log */ /** @var ILogger $log */
private $log; private $log;
/** @var \OC\HTTPHelper $helper */ /** @var \OC\HTTPHelper $helper */
@ -67,9 +68,9 @@ class Updater extends BasicEmitter {
/** /**
* @param HTTPHelper $httpHelper * @param HTTPHelper $httpHelper
* @param IConfig $config * @param IConfig $config
* @param \OC\Log $log * @param ILogger $log
*/ */
public function __construct(HTTPHelper $httpHelper, IConfig $config, $log = null) { public function __construct(HTTPHelper $httpHelper, IConfig $config, ILogger $log = null) {
$this->httpHelper = $httpHelper; $this->httpHelper = $httpHelper;
$this->log = $log; $this->log = $log;
$this->config = $config; $this->config = $config;

View File

@ -22,6 +22,7 @@
*/ */
namespace OCP\BackgroundJob; namespace OCP\BackgroundJob;
use OCP\ILogger;
/** /**
* Interface IJob * Interface IJob
@ -34,11 +35,11 @@ interface IJob {
* Run the background job with the registered argument * Run the background job with the registered argument
* *
* @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job
* @param \OC\Log $logger * @param ILogger $logger
* @return void * @return void
* @since 7.0.0 * @since 7.0.0
*/ */
public function execute($jobList, $logger = null); public function execute($jobList, ILogger $logger = null);
/** /**
* Get the id of the background job * Get the id of the background job