Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Fix debug logging. Move logging to application #1303

Closed
jgerman-bot opened this issue Oct 16, 2020 · 0 comments · Fixed by #1361
Closed

[4.0] Fix debug logging. Move logging to application #1303

jgerman-bot opened this issue Oct 16, 2020 · 0 comments · Fixed by #1361

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#30317 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_config/forms/application.xml b/administrator/components/com_config/forms/application.xml
index 7a68d34a6023..8b944295fac2 100644
--- a/administrator/components/com_config/forms/application.xml
+++ b/administrator/components/com_config/forms/application.xml
@@ -1098,8 +1098,8 @@
 	</fieldset>
 
 	<fieldset
-		name="system"
-		label="CONFIG_SYSTEM_SETTINGS_LABEL">
+		name="logging"
+		label="CONFIG_LOGGING_SETTINGS_LABEL">
 
 		<field
 			name="log_path"
@@ -1110,6 +1110,77 @@
 			size="50"
 		/>
 
+		<field
+			name="log_everything"
+			type="radio"
+			label="COM_CONFIG_FIELD_LOG_EVERYTHING_LABEL"
+			description="COM_CONFIG_FIELD_LOG_EVERYTHING_DESC"
+			layout="joomla.form.field.radio.switcher"
+			default="0"
+			filter="integer"
+			>
+			<option value="0">JNO</option>
+			<option value="1">JYES</option>
+		</field>
+
+		<field
+			name="log_deprecated"
+			type="radio"
+			label="COM_CONFIG_FIELD_LOG_DEPRECATED_LABEL"
+			layout="joomla.form.field.radio.switcher"
+			default="0"
+			filter="integer"
+			>
+			<option value="0">JNO</option>
+			<option value="1">JYES</option>
+		</field>
+	</fieldset>
+
+	<fieldset
+		name="logging_custom"
+		label="CONFIG_LOGGING_CUSTOM_SETTINGS_LABEL">
+
+		<field
+			name="log_priorities"
+			type="list"
+			label="COM_CONFIG_FIELD_LOG_PRIORITIES_LABEL"
+			multiple="true"
+			layout="joomla.form.field.list-fancy-select"
+			default="all"
+			validate="options"
+			>
+			<option value="all">COM_CONFIG_FIELD_LOG_PRIORITIES_ALL</option>
+			<option value="emergency">COM_CONFIG_FIELD_LOG_PRIORITIES_EMERGENCY</option>
+			<option value="alert">COM_CONFIG_FIELD_LOG_PRIORITIES_ALERT</option>
+			<option value="critical">COM_CONFIG_FIELD_LOG_PRIORITIES_CRITICAL</option>
+			<option value="error">COM_CONFIG_FIELD_LOG_PRIORITIES_ERROR</option>
+			<option value="warning">COM_CONFIG_FIELD_LOG_PRIORITIES_WARNING</option>
+			<option value="notice">COM_CONFIG_FIELD_LOG_PRIORITIES_NOTICE</option>
+			<option value="info">COM_CONFIG_FIELD_LOG_PRIORITIES_INFO</option>
+			<option value="debug">COM_CONFIG_FIELD_LOG_PRIORITIES_DEBUG</option>
+		</field>
+
+		<field
+			name="log_categories"
+			type="text"
+			label="COM_CONFIG_FIELD_LOG_CATEGORIES_LABEL"
+			description="COM_CONFIG_FIELD_LOG_CATEGORIES_DESC"
+			size="60"
+			default=""
+		/>
+
+		<field
+			name="log_category_mode"
+			type="radio"
+			label="COM_CONFIG_FIELD_LOG_CATEGORY_MODE_LABEL"
+			layout="joomla.form.field.radio.switcher"
+			default="0"
+			filter="integer"
+			>
+			<option value="0">COM_CONFIG_FIELD_LOG_CATEGORY_MODE_INCLUDE</option>
+			<option value="1">COM_CONFIG_FIELD_LOG_CATEGORY_MODE_EXCLUDE</option>
+		</field>
+
 	</fieldset>
 
 	<fieldset
diff --git a/administrator/components/com_config/tmpl/application/default.php b/administrator/components/com_config/tmpl/application/default.php
index 6283a9bf6468..4c092033e670 100644
--- a/administrator/components/com_config/tmpl/application/default.php
+++ b/administrator/components/com_config/tmpl/application/default.php
@@ -48,7 +48,6 @@
 				<?php echo HTMLHelper::_('uitab.endTab'); ?>
 
 				<?php echo HTMLHelper::_('uitab.addTab', 'configTabs', 'page-system', Text::_('COM_CONFIG_SYSTEM')); ?>
-					<?php echo $this->loadTemplate('system'); ?>
 					<?php echo $this->loadTemplate('debug'); ?>
 					<?php echo $this->loadTemplate('cache'); ?>
 					<?php echo $this->loadTemplate('session'); ?>
@@ -63,6 +62,11 @@
 					<?php echo $this->loadTemplate('mail'); ?>
 				<?php echo HTMLHelper::_('uitab.endTab'); ?>
 
+				<?php echo HTMLHelper::_('uitab.addTab', 'configTabs', 'page-logging', Text::_('COM_CONFIG_LOGGING')); ?>
+					<?php echo $this->loadTemplate('logging'); ?>
+					<?php echo $this->loadTemplate('logging_custom'); ?>
+				<?php echo HTMLHelper::_('uitab.endTab'); ?>
+
 				<?php echo HTMLHelper::_('uitab.addTab', 'configTabs', 'page-filters', Text::_('COM_CONFIG_TEXT_FILTERS')); ?>
 					<?php echo $this->loadTemplate('filters'); ?>
 				<?php echo HTMLHelper::_('uitab.endTab'); ?>
diff --git a/administrator/components/com_config/tmpl/application/default_system.php b/administrator/components/com_config/tmpl/application/default_logging.php
similarity index 84%
rename from administrator/components/com_config/tmpl/application/default_system.php
rename to administrator/components/com_config/tmpl/application/default_logging.php
index ea4c51af10b6..64a8d17e8515 100644
--- a/administrator/components/com_config/tmpl/application/default_system.php
+++ b/administrator/components/com_config/tmpl/application/default_logging.php
@@ -12,8 +12,8 @@
 
 defined('_JEXEC') or die;
 
-$this->name = Text::_('COM_CONFIG_SYSTEM_SETTINGS');
-$this->fieldsname = 'system';
+$this->name = Text::_('COM_CONFIG_LOGGING_SETTINGS');
+$this->fieldsname = 'logging';
 $this->formclass = 'options-form';
 
 echo LayoutHelper::render('joomla.content.options_default', $this);
diff --git a/administrator/components/com_config/tmpl/application/default_logging_custom.php b/administrator/components/com_config/tmpl/application/default_logging_custom.php
new file mode 100644
index 000000000000..636611c0497b
--- /dev/null
+++ b/administrator/components/com_config/tmpl/application/default_logging_custom.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @package     Joomla.Administrator
+ * @subpackage  com_config
+ *
+ * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
+ * @license     GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Layout\LayoutHelper;
+
+defined('_JEXEC') or die;
+
+$this->name = Text::_('COM_CONFIG_LOGGING_CUSTOM_SETTINGS');
+$this->fieldsname = 'logging_custom';
+$this->formclass = 'options-form';
+
+echo LayoutHelper::render('joomla.content.options_default', $this);
diff --git a/administrator/language/en-GB/com_config.ini b/administrator/language/en-GB/com_config.ini
index 5f375e537f8e..787f8d3d1e86 100644
--- a/administrator/language/en-GB/com_config.ini
+++ b/administrator/language/en-GB/com_config.ini
@@ -84,7 +84,25 @@ COM_CONFIG_FIELD_FTP_ROOT_LABEL="FTP Root"
 COM_CONFIG_FIELD_FTP_USERNAME_LABEL="FTP Username"
 COM_CONFIG_FIELD_GZIP_COMPRESSION_LABEL="Gzip Page Compression"
 COM_CONFIG_FIELD_HTMLBODY_LABEL="HTML Body"
+COM_CONFIG_FIELD_LOG_CATEGORIES_DESC="A comma separated list of log categories to include. Common log categories include but are not limited to: database, databasequery, database-error, deprecated and jerror. If empty, all categories will be shown."
+COM_CONFIG_FIELD_LOG_CATEGORIES_LABEL="Log Categories"
+COM_CONFIG_FIELD_LOG_CATEGORY_MODE_EXCLUDE="Exclude"
+COM_CONFIG_FIELD_LOG_CATEGORY_MODE_INCLUDE="Include"
+COM_CONFIG_FIELD_LOG_CATEGORY_MODE_LABEL="Log Category Mode"
+COM_CONFIG_FIELD_LOG_DEPRECATED_LABEL="Log Deprecated API"
+COM_CONFIG_FIELD_LOG_EVERYTHING_LABEL="Log Almost Everything"
+COM_CONFIG_FIELD_LOG_EVERYTHING_DESC="Logs everything, except deprecated APIs."
 COM_CONFIG_FIELD_LOG_PATH_LABEL="Path to Log Folder"
+COM_CONFIG_FIELD_LOG_PRIORITIES_ALERT="Alert"
+COM_CONFIG_FIELD_LOG_PRIORITIES_ALL="All"
+COM_CONFIG_FIELD_LOG_PRIORITIES_CRITICAL="Critical"
+COM_CONFIG_FIELD_LOG_PRIORITIES_DEBUG="Debug"
+COM_CONFIG_FIELD_LOG_PRIORITIES_EMERGENCY="Emergency"
+COM_CONFIG_FIELD_LOG_PRIORITIES_ERROR="Error"
+COM_CONFIG_FIELD_LOG_PRIORITIES_INFO="Info"
+COM_CONFIG_FIELD_LOG_PRIORITIES_LABEL="Log Priorities"
+COM_CONFIG_FIELD_LOG_PRIORITIES_NOTICE="Notice"
+COM_CONFIG_FIELD_LOG_PRIORITIES_WARNING="Warning"
 COM_CONFIG_FIELD_MAIL_FROM_EMAIL_LABEL="From Email"
 COM_CONFIG_FIELD_MAIL_FROM_NAME_LABEL="From Name"
 COM_CONFIG_FIELD_MAIL_MAILER_LABEL="Mailer"
@@ -170,6 +188,9 @@ COM_CONFIG_HEADING_COMPONENT="Component"
 COM_CONFIG_HEADING_DESCRIPTION="Description"
 COM_CONFIG_HEADING_LANUAGES="Languages"
 COM_CONFIG_LOCATION_SETTINGS="Location"
+COM_CONFIG_LOGGING="Logging"
+COM_CONFIG_LOGGING_CUSTOM_SETTINGS="Custom logging"
+COM_CONFIG_LOGGING_SETTINGS="Logging"
 COM_CONFIG_MAIL_SETTINGS="Mail"
 COM_CONFIG_MAIL_TEST_MAIL_DESC="Sent when you click the &quot;Send Test Mail&quot; button in the Global Configuration. It is sent to the sending mail address that is set in the mail settings."
 COM_CONFIG_MAIL_TEST_MAIL_TITLE="Global Configuration: Test Mail"
diff --git a/administrator/language/en-GB/plg_system_debug.ini b/administrator/language/en-GB/plg_system_debug.ini
index 76d2dd21339f..dc1139908bf3 100644
--- a/administrator/language/en-GB/plg_system_debug.ini
+++ b/administrator/language/en-GB/plg_system_debug.ini
@@ -14,24 +14,7 @@ PLG_DEBUG_FIELD_ALLOWED_GROUPS_LABEL="Allowed Groups"
 PLG_DEBUG_FIELD_LANGUAGE_ERRORFILES_LABEL="Errors When Parsing Language Files"
 PLG_DEBUG_FIELD_LANGUAGE_FILES_LABEL="Language Files"
 PLG_DEBUG_FIELD_LANGUAGE_STRING_LABEL="Language String"
-PLG_DEBUG_FIELD_LOG_CATEGORIES_DESC="A comma separated list of log categories to include. Common log categories include but are not limited to: database, databasequery, database-error, deprecated and jerror. If empty, all categories will be shown."
-PLG_DEBUG_FIELD_LOG_CATEGORIES_LABEL="Log Categories"
-PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_EXCLUDE="Exclude"
-PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_INCLUDE="Include"
-PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_LABEL="Log Category Mode"
-PLG_DEBUG_FIELD_LOG_DEPRECATED_CORE_LABEL="Log Deprecated Core API"
-PLG_DEBUG_FIELD_LOG_DEPRECATED_LABEL="Log Deprecated API"
-PLG_DEBUG_FIELD_LOG_EVERYTHING_LABEL="Log Almost Everything"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_ALERT="Alert"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_ALL="All"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_CRITICAL="Critical"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_DEBUG="Debug"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_EMERGENCY="Emergency"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_ERROR="Error"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_INFO="Info"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_LABEL="Log Priorities"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_NOTICE="Notice"
-PLG_DEBUG_FIELD_LOG_PRIORITIES_WARNING="Warning"
+PLG_DEBUG_FIELD_LOG_DEPRECATED_CORE_LABEL="Split Deprecated Core API"
 PLG_DEBUG_FIELD_LOGS_LABEL="Log Entries"
 PLG_DEBUG_FIELD_MEMORY_LABEL="Memory Usage"
 PLG_DEBUG_FIELD_PROFILING_LABEL="Profiling"
diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php
index afc3c3f3c3c8..d8d9e0629f6a 100644
--- a/libraries/src/Application/CMSApplication.php
+++ b/libraries/src/Application/CMSApplication.php
@@ -22,6 +22,7 @@
 use Joomla\CMS\Input\Input;
 use Joomla\CMS\Language\Language;
 use Joomla\CMS\Language\Text;
+use Joomla\CMS\Log\Log;
 use Joomla\CMS\Menu\AbstractMenu;
 use Joomla\CMS\Pathway\Pathway;
 use Joomla\CMS\Plugin\PluginHelper;
@@ -225,6 +226,7 @@ public function execute()
 	{
 		try
 		{
+			$this->setupLogging();
 			$this->createExtensionNamespaceMap();
 
 			// Perform application routines.
@@ -1309,4 +1311,58 @@ private function hasUserConfiguredTwoFactorAuthentication(): bool
 
 		return true;
 	}
+
+	/**
+	 * Setup logging functionality.
+	 *
+	 * @return void
+	 *
+	 * @since   __DEPLOY_VERSION__
+	 */
+	private function setupLogging(): void
+	{
+		// Add InMemory logger that will collect all log entries to allow to display them later by extensions
+		if ($this->get('debug'))
+		{
+			Log::addLogger(['logger' => 'inmemory']);
+		}
+
+		// Log the deprecated API.
+		if ($this->get('log_deprecated'))
+		{
+			Log::addLogger(['text_file' => 'deprecated.php'], Log::ALL, ['deprecated']);
+		}
+
+		// Log everything (except deprecated APIs, these are logged separately with the option above).
+		if ($this->get('log_everything'))
+		{
+			Log::addLogger(['text_file' => 'everything.php'], Log::ALL, ['deprecated', 'deprecation-notes', 'databasequery'], true);
+		}
+
+		if ($this->get('log_categories'))
+		{
+			$priority = 0;
+
+			foreach ($this->get('log_priorities', ['all']) as $p)
+			{
+				$const = '\\Joomla\\CMS\\Log\\Log::' . strtoupper($p);
+
+				if (defined($const))
+				{
+					$priority |= constant($const);
+				}
+			}
+
+			// Split into an array at any character other than alphabet, numbers, _, ., or -
+			$categories = preg_split('/[^\w.-]+/', $this->get('log_categories', ''), -1, PREG_SPLIT_NO_EMPTY);
+			$mode       = (bool) $this->get('log_category_mode', false);
+
+			if (!$categories)
+			{
+				return;
+			}
+
+			Log::addLogger(['text_file' => 'custom-logging.php'], $priority, $categories, $mode);
+		}
+	}
 }
diff --git a/libraries/src/Log/Logger/InMemoryLogger.php b/libraries/src/Log/Logger/InMemoryLogger.php
new file mode 100644
index 000000000000..f33a0e746f1c
--- /dev/null
+++ b/libraries/src/Log/Logger/InMemoryLogger.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Joomla! Content Management System
+ *
+ * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
+ * @license    GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+namespace Joomla\CMS\Log\Logger;
+
+\defined('JPATH_PLATFORM') or die;
+
+use Joomla\CMS\Log\LogEntry;
+use Joomla\CMS\Log\Logger;
+
+/**
+ * Logger class that keeps all entries in memory
+ *
+ * @since  4.0.0
+ */
+class InMemoryLogger extends Logger
+{
+	/**
+	 * List of collected log entries, grouped by $group
+	 *
+	 * @var array
+	 * @since  4.0.0
+	 */
+	protected static $logEntries = [];
+
+	/**
+	 * Group name to store the entries
+	 *
+	 * @var    string
+	 * @since  4.0.0
+	 */
+	protected $group = 'default';
+
+	/**
+	 * Constructor.
+	 *
+	 * @param   array  &$options  Log object options.
+	 *
+	 * @since   4.0.0
+	 */
+	public function __construct(array &$options)
+	{
+		parent::__construct($options);
+
+		if (!empty($this->options['group']))
+		{
+			$this->group = $this->options['group'];
+		}
+	}
+
+	/**
+	 * Method to add an entry to the log.
+	 *
+	 * @param   LogEntry  $entry  The log entry object to add to the log.
+	 *
+	 * @return  void
+	 *
+	 * @since   4.0.0
+	 */
+	public function addEntry(LogEntry $entry)
+	{
+		static::$logEntries[$this->group][] = $entry;
+	}
+
+	/**
+	 * Returns a list of collected entries.
+	 *
+	 * @return  array
+	 *
+	 * @since   4.0.0
+	 */
+	public function getCollectedEntries()
+	{
+		if (empty(static::$logEntries[$this->group]))
+		{
+			return [];
+		}
+
+		return static::$logEntries[$this->group];
+	}
+}
diff --git a/libraries/src/Log/LoggerRegistry.php b/libraries/src/Log/LoggerRegistry.php
index 9ac2ec12b984..155ebf348ec5 100644
--- a/libraries/src/Log/LoggerRegistry.php
+++ b/libraries/src/Log/LoggerRegistry.php
@@ -31,6 +31,7 @@ final class LoggerRegistry
 		'messagequeue'  => Logger\MessagequeueLogger::class,
 		'syslog'        => Logger\SyslogLogger::class,
 		'w3c'           => Logger\W3cLogger::class,
+		'inmemory'      => Logger\InMemoryLogger::class,
 	];
 
 	/**
diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php
index 2fc746daa84e..61c869907741 100644
--- a/plugins/system/debug/debug.php
+++ b/plugins/system/debug/debug.php
@@ -126,6 +126,14 @@ class PlgSystemDebug extends CMSPlugin
 	 */
 	protected $isAjax = false;
 
+	/**
+	 * Whether displaing a logs is enabled
+	 *
+	 * @var   bool
+	 * @since 4.0.0
+	 */
+	protected $showLogs = false;
+
 	/**
 	 * Constructor.
 	 *
@@ -167,7 +175,7 @@ public function __construct(&$subject, $config)
 		$this->isAjax = $this->app->input->get('option') === 'com_ajax'
 			&& $this->app->input->get('plugin') === 'debug' && $this->app->input->get('group') === 'system';
 
-		$this->setupLogging();
+		$this->showLogs = (bool) $this->params->get('logs', false);
 	}
 
 	/**
@@ -206,6 +214,24 @@ public function onAfterDispatch()
 		{
 			$this->app->getDocument()->setMediaVersion(null);
 		}
+
+		// Log deprecated class aliases
+		if ($this->showLogs && $this->app->get('log_deprecated'))
+		{
+			foreach (JLoader::getDeprecatedAliases() as $deprecation)
+			{
+				Log::add(
+					sprintf(
+						'%1$s has been aliased to %2$s and the former class name is deprecated. The alias will be removed in %3$s.',
+						$deprecation['old'],
+						$deprecation['new'],
+						$deprecation['version']
+					),
+					Log::WARNING,
+					'deprecation-notes'
+				);
+			}
+		}
 	}
 
 	/**
@@ -263,7 +289,7 @@ public function onAfterRespond()
 				$this->debugBar->addCollector(new QueryCollector($this->params, $this->queryMonitor, $this->sqlShowProfileEach, $this->explains));
 			}
 
-			if (!empty($this->logEntries) && $this->params->get('logs', 1))
+			if ($this->showLogs)
 			{
 				$this->collectLogs();
 			}
@@ -351,66 +377,6 @@ public function onAjaxDebug()
 		}
 	}
 
-	/**
-	 * Setup logging functionality.
-	 *
-	 * @return $this
-	 *
-	 * @since 4.0.0
-	 */
-	private function setupLogging(): self
-	{
-		// Log the deprecated API.
-		if ($this->params->get('log-deprecated'))
-		{
-			Log::addLogger(['text_file' => 'deprecated.php'], Log::ALL, ['deprecated']);
-		}
-
-		// Log everything (except deprecated APIs, these are logged separately with the option above).
-		if ($this->params->get('log-everything', 0))
-		{
-			Log::addLogger(['text_file' => 'everything.php'], Log::ALL, ['deprecated', 'databasequery'], true);
-		}
-
-		if ($this->params->get('logs', 1))
-		{
-			$priority = 0;
-
-			foreach ($this->params->get('log_priorities', []) as $p)
-			{
-				$const = '\\Joomla\\CMS\\Log\\Log::' . strtoupper($p);
-
-				if (defined($const))
-				{
-					$priority |= constant($const);
-				}
-			}
-
-			// Split into an array at any character other than alphabet, numbers, _, ., or -
-			$categories = preg_split('/[^\w.-]+/', $this->params->get('log_categories', ''), -1, PREG_SPLIT_NO_EMPTY);
-			$mode = $this->params->get('log_category_mode', 0);
-
-			Log::addLogger(['logger' => 'callback', 'callback' => [$this, 'logger']], $priority, $categories, $mode);
-		}
-
-		// Log deprecated class aliases
-		foreach (JLoader::getDeprecatedAliases() as $deprecation)
-		{
-			Log::add(
-				sprintf(
-					'%1$s has been aliased to %2$s and the former class name is deprecated. The alias will be removed in %3$s.',
-					$deprecation['old'],
-					$deprecation['new'],
-					$deprecation['version']
-				),
-				Log::WARNING,
-				'deprecation-notes'
-			);
-		}
-
-		return $this;
-	}
-
 	/**
 	 * Method to check if the current user is allowed to see the debug information or not.
 	 *
@@ -544,9 +510,16 @@ public function onAfterDisconnect(ConnectionEvent $event)
 	 * @return  void
 	 *
 	 * @since   3.1
+	 *
+	 * @deprecated  5.0  Use Log::add(LogEntry $entry);
 	 */
 	public function logger(LogEntry $entry)
 	{
+		if (!$this->showLogs)
+		{
+			return;
+		}
+
 		$this->logEntries[] = $entry;
 	}
 
@@ -559,12 +532,21 @@ public function logger(LogEntry $entry)
 	 */
 	private function collectLogs(): self
 	{
-		if (!$this->logEntries)
+		$loggerOptions = ['group' => 'default'];
+		$logger        = new Joomla\CMS\Log\Logger\InMemoryLogger($loggerOptions);
+		$logEntries    = $logger->getCollectedEntries();
+
+		if (!$this->logEntries && !$logEntries)
 		{
 			return $this;
 		}
 
-		$logDeprecated = $this->params->get('log-deprecated', 0);
+		if ($this->logEntries)
+		{
+			$logEntries = array_merge($logEntries, $this->logEntries);
+		}
+
+		$logDeprecated = $this->app->get('log_deprecated', 0);
 		$logDeprecatedCore = $this->params->get('log-deprecated-core', 0);
 
 		$this->debugBar->addCollector(new MessagesCollector('log'));
@@ -580,7 +562,7 @@ private function collectLogs(): self
 			$this->debugBar->addCollector(new MessagesCollector('deprecated-core'));
 		}
 
-		foreach ($this->logEntries as $entry)
+		foreach ($logEntries as $entry)
 		{
 			switch ($entry->category)
 			{
diff --git a/plugins/system/debug/debug.xml b/plugins/system/debug/debug.xml
index cc62ac413348..26509a1c46fa 100644
--- a/plugins/system/debug/debug.xml
+++ b/plugins/system/debug/debug.xml
@@ -230,58 +230,6 @@
 					<option value="1">JSHOW</option>
 				</field>
 
-				<field
-					name="log_priorities"
-					type="list"
-					label="PLG_DEBUG_FIELD_LOG_PRIORITIES_LABEL"
-					multiple="true"
-					layout="joomla.form.field.list-fancy-select"
-					default="all"
-					validate="options"
-					>
-					<option value="all">PLG_DEBUG_FIELD_LOG_PRIORITIES_ALL</option>
-					<option value="emergency">PLG_DEBUG_FIELD_LOG_PRIORITIES_EMERGENCY</option>
-					<option value="alert">PLG_DEBUG_FIELD_LOG_PRIORITIES_ALERT</option>
-					<option value="critical">PLG_DEBUG_FIELD_LOG_PRIORITIES_CRITICAL</option>
-					<option value="error">PLG_DEBUG_FIELD_LOG_PRIORITIES_ERROR</option>
-					<option value="warning">PLG_DEBUG_FIELD_LOG_PRIORITIES_WARNING</option>
-					<option value="notice">PLG_DEBUG_FIELD_LOG_PRIORITIES_NOTICE</option>
-					<option value="info">PLG_DEBUG_FIELD_LOG_PRIORITIES_INFO</option>
-					<option value="debug">PLG_DEBUG_FIELD_LOG_PRIORITIES_DEBUG</option>
-				</field>
-
-				<field
-					name="log_categories"
-					type="text"
-					label="PLG_DEBUG_FIELD_LOG_CATEGORIES_LABEL"
-					description="PLG_DEBUG_FIELD_LOG_CATEGORIES_DESC"
-					size="60"
-					default=""
-				/>
-
-				<field
-					name="log_category_mode"
-					type="radio"
-					label="PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_LABEL"
-					layout="joomla.form.field.radio.switcher"
-					default="0"
-					>
-					<option value="0">PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_INCLUDE</option>
-					<option value="1">PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_EXCLUDE</option>
-				</field>
-
-				<field
-					name="log-deprecated"
-					type="radio"
-					label="PLG_DEBUG_FIELD_LOG_DEPRECATED_LABEL"
-					layout="joomla.form.field.radio.switcher"
-					default="0"
-					filter="integer"
-					>
-					<option value="0">JNO</option>
-					<option value="1">JYES</option>
-				</field>
-
 				<field
 					name="log-deprecated-core"
 					type="radio"
@@ -289,22 +237,12 @@
 					layout="joomla.form.field.radio.switcher"
 					default="0"
 					filter="integer"
+					showon="logs:1"
 					>
 					<option value="0">JNO</option>
 					<option value="1">JYES</option>
 				</field>
 
-				<field
-					name="log-everything"
-					type="radio"
-					label="PLG_DEBUG_FIELD_LOG_EVERYTHING_LABEL"
-					layout="joomla.form.field.radio.switcher"
-					default="0"
-					filter="integer"
-					>
-					<option value="0">JNO</option>
-					<option value="1">JYES</option>
-				</field>
 			</fieldset>
 		</fields>
 	</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants