I use the Joomla! Logger in the installation script file of a custom Joomla! component (Visforms), in order to write a log file.
I use the following Code to include the Joomla! Logger and extend the JLogLoggerFormattedtext
...
jimport('joomla.log.log');
class JLogLoggerFormattedtextVisforms extends JLogLoggerFormattedtext
{
protected $priorities = array(
JLog::EMERGENCY => 'EMG',
JLog::ALERT => 'ALT',
JLog::CRITICAL => 'CRI',
JLog::ERROR => 'ERR',
JLog::WARNING => 'WRN',
JLog::NOTICE => 'NTC',
JLog::INFO => 'INF',
JLog::DEBUG => 'DBG'
);
public function addEntry(JLogEntry $entry)
{
try {
@parent::addEntry($entry);
} catch (RuntimeException $e) {
//prevent installation from being aborted as failed, if we cannot write the log file
}
}
}
class com_visformsInstallerScript
{
...
}
Installing the component on Joomla! 3.8.0 rc1 fails whereas the exact same installation works on Joomla! 3.7.5 properly without any problems
Visforms is available from JED through "Install from Web", if you want to reproduce the problem.
Install on Joomla! 3.7.5 works without problems. (Message: Message "Installation of the component was successful.")
Install on Joomla! 3.8.0 rc1 throws the error message:
Unable to create a Logger instance: Joomla\CMS\Log\Logger\FormattedtextvisformsLogger
On Joomla! 3.8.0 rc1 although: Message "Installation of the component was successful."
error message:
Unable to create a Logger instance: Joomla\CMS\Log\Logger\FormattedtextvisformsLogger
php 7.1.7 on local XAMPP 7.1.7
I actually think I have extended the Joomla! Logger in the intended way and that the code posted above should still work with Joomla! 3.8.0, so this is a backward compatibility problem with the installer.
I think after moving the Logger to the librairies/src folder with Joomla! 3.8.0 it is now necessary to use the proper namespace, which should be implemented by the Joomla! installer.
Please let me know, if I'm wrong.
Regards,
Aicha
Priority | Urgent | ⇒ | Medium |
I needed to refactor my logger and use the namespace based way to implement it. I don't like the need to use the Joomla namespace for my logging class. The class FormattedtextLogger should contain all one needs to adjust his implementation.
Still, I would love to see that this change does not break working code
Still, I would love to see that this change does not break working code
@svenbluege hmm do you think we are gods? The better question is did you test your code against the beta / rc versions?
Status | New | ⇒ | Discussion |
I needed to refactor my logger and use the namespace based way to implement it. I don't like the need to use the Joomla namespace for my logging class. The class FormattedtextLogger should contain all one needs to adjust his implementation.
Everything in our API that enforces class name structure (a forced namespace or class prefix in the Joomla class name areas) needs refactoring to use some form of service registry approach. The odds of that happening are slim to none though to be honest, just because there aren't many actively contributing coders that would be willing to do this work, and there aren't many actively contributing coders that would be able to test and review said work. So sadly I think we might be permanently stuck with "if you're extending a core feature you have to use our namespaces".
Status | Discussion | ⇒ | Closed - Unconfirmed Report |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-03-18 02:45:47 |
Closed_By | ⇒ | jwaisner |
Status | Closed - Unconfirmed Report | ⇒ | Closed |
Closed_By | jwaisner | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @jwaisner by The JTracker Application at issues.joomla.org/joomla-cms/17972
Closing as not a bug as it was confirmed by creator that it works now.
I needed to refactor my logger and use the namespace based way to implement it. I don't like the need to use the Joomla namespace for my logging class. The class FormattedtextLogger should contain all one needs to adjust his implementation.
Still, I would love to see that this change does not break working code
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17972.