J3 Issue ?
avatar avjoomla
avjoomla
16 Sep 2017

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

Steps to reproduce the issue

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

Expected result

On Joomla! 3.8.0 rc1 although: Message "Installation of the component was successful."

Actual result

error message:
Unable to create a Logger instance: Joomla\CMS\Log\Logger\FormattedtextvisformsLogger

System information (as much as possible)

php 7.1.7 on local XAMPP 7.1.7

Additional comments

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

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar avjoomla avjoomla - open - 16 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Sep 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Sep 2017
Priority Urgent Medium
avatar svenbluege
svenbluege - comment - 20 Sep 2017

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.
avatar svenbluege
svenbluege - comment - 20 Sep 2017

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.
avatar zero-24
zero-24 - comment - 20 Sep 2017

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?

avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Sep 2017
Status New Discussion
avatar svenbluege
svenbluege - comment - 20 Sep 2017

@zero-24 did not expect enabled god mode ;-)

I actually tested until 3.8.0-rc2 without seeing this issue. I guess this is because I missed testing the error cases where the logging gets active.

avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar mbabker
mbabker - comment - 24 Jul 2018

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".

avatar jwaisner jwaisner - change - 18 Mar 2020
Status Discussion Closed - Unconfirmed Report
Closed_Date 0000-00-00 00:00:00 2020-03-18 02:45:47
Closed_By jwaisner
avatar joomla-cms-bot joomla-cms-bot - change - 18 Mar 2020
Status Closed - Unconfirmed Report Closed
Closed_By jwaisner joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 18 Mar 2020
avatar joomla-cms-bot
joomla-cms-bot - comment - 18 Mar 2020

Set to "closed" on behalf of @jwaisner by The JTracker Application at issues.joomla.org/joomla-cms/17972

avatar jwaisner
jwaisner - comment - 18 Mar 2020

Closing as not a bug as it was confirmed by creator that it works now.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17972.

Add a Comment

Login with GitHub to post a comment