Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-12-04 08:29:33 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-12-04 08:29:33 +0300
commita59667bf04c670e26c1116985481e688084efc4f (patch)
treea5d1ca9a9ce30720e6b1ad07d06e09796123b204
parent14cf2581242c75907fb554e08a30041ad107f558 (diff)
#6622 Logger refactoring: removed the "Log.getAvailableWriters" event
Adding new log backends will later be possible by configuring Monolog handlers
-rw-r--r--CHANGELOG.md1
-rw-r--r--core/Log.php2
-rw-r--r--core/Log/LoggerFactory.php58
3 files changed, 9 insertions, 52 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c02dfd9c1c..9d8c633871 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API'
* `Log.formatDatabaseMessage`
* `Log.formatScreenMessage`
* These events where very specific events for an internal need (logging exceptions) and have been replaced by a more extensible solution.
+* The event `Log.getAvailableWriters` has been removed: to add custom log backends, you now need to configure Monolog handlers
### Deprecations
* The API method `UserSettings.getBrowserVersion` is deprecated and will be removed from May 1st 2015. Use `DevicesDetection.getBrowserVersions` instead
diff --git a/core/Log.php b/core/Log.php
index 8bcf91df9c..d22b88160b 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -114,8 +114,6 @@ class Log extends Singleton
const LOGGER_FILE_PATH_CONFIG_OPTION = 'logger_file_path';
const STRING_MESSAGE_FORMAT_OPTION = 'string_message_format';
- const GET_AVAILABLE_WRITERS_EVENT = 'Log.getAvailableWriters';
-
/**
* The backtrace string to use when testing.
*
diff --git a/core/Log/LoggerFactory.php b/core/Log/LoggerFactory.php
index f9f437d468..fe783cb42c 100644
--- a/core/Log/LoggerFactory.php
+++ b/core/Log/LoggerFactory.php
@@ -12,7 +12,6 @@ use Interop\Container\ContainerInterface;
use Piwik\Config;
use Piwik\Log;
use Piwik\Log\Backend\StdErrBackend;
-use Piwik\Piwik;
class LoggerFactory
{
@@ -39,22 +38,20 @@ class LoggerFactory
return array();
}
- $availableWriters = self::getAvailableWriters();
+ $classes = array(
+ 'file' => 'Piwik\Log\Backend\FileBackend',
+ 'screen' => 'Piwik\Log\Backend\StdOutBackend',
+ 'database' => 'Piwik\Log\Backend\DatabaseBackend',
+ );
$writerNames = array_map('trim', $writerNames);
$writers = array();
foreach ($writerNames as $writerName) {
- if (! isset($availableWriters[$writerName])) {
- continue;
+ if (isset($classes[$writerName])) {
+ $class = $classes[$writerName];
+ $writers[$writerName] = $container->get($class);
}
-
- $writer = $availableWriters[$writerName];
- if (is_string($writer)) {
- $writer = $container->get($writer);
- }
-
- $writers[$writerName] = $writer;
}
// Always add the stderr backend
@@ -63,43 +60,4 @@ class LoggerFactory
return $writers;
}
-
- private static function getAvailableWriters()
- {
- $writers = array();
-
- /**
- * This event is called when the Log instance is created. Plugins can use this event to
- * make new logging writers available.
- *
- * A logging writer is a callback with the following signature:
- *
- * function (int $level, string $tag, string $datetime, string $message)
- *
- * `$level` is the log level to use, `$tag` is the log tag used, `$datetime` is the date time
- * of the logging call and `$message` is the formatted log message.
- *
- * Logging writers must be associated by name in the array passed to event handlers. The
- * name specified can be used in Piwik's INI configuration.
- *
- * **Example**
- *
- * public function getAvailableWriters(&$writers) {
- * $writers['myloggername'] = function ($level, $tag, $datetime, $message) {
- * // ...
- * };
- * }
- *
- * // 'myloggername' can now be used in the log_writers config option.
- *
- * @param array $writers Array mapping writer names with logging writers.
- */
- Piwik::postEvent(Log::GET_AVAILABLE_WRITERS_EVENT, array(&$writers));
-
- $writers['file'] = 'Piwik\Log\Backend\FileBackend';
- $writers['screen'] = 'Piwik\Log\Backend\StdOutBackend';
- $writers['database'] = 'Piwik\Log\Backend\DatabaseBackend';
-
- return $writers;
- }
}