Logging API for Frog Dashboard
May 18th, 2009

Dashboard plugin for Frog CMS now provides simple API for other developers to log their events. Whenever you want to log something to dashboard just trigger a log event. Include your message as parameter.
Observer::notify('log_event', 'Something was done by :username.');
In your message you can include string :username to log the user name.
Priority and Ident
You can also provide priority and ident for the log message. Priority is used to inform about severity of the message. Ident is used to identify sender of the message. Plugin developers should use the ident of their plugin. For example Funky Cache plugin uses funky_cache as ident.
Observer::notify('log_event', 'Something else was done by :username.',
DASHBOARD_LOG_NOTICE, 'pluginname');
Priorities are defined in Dashboard code.
define('DASHBOARD_LOG_EMERG', 0); /* system no longer available */
define('DASHBOARD_LOG_ALERT', 1); /* immediate action required */
define('DASHBOARD_LOG_CRIT', 2); /* critical condition */
define('DASHBOARD_LOG_ERR', 3); /* error condition */
define('DASHBOARD_LOG_WARNING', 4); /* warning messages */
define('DASHBOARD_LOG_NOTICE', 5); /* normal, but significant, condition */
define('DASHBOARD_LOG_INFO', 6); /* general informative messages */
define('DASHBOARD_LOG_DEBUG', 7); /* debugging information */
If your code uses constants and Frog is in debug mode and Dashboard plugin is not installed this will cause PHP to display “Use of undefined constant” warnings. If you want to be sure your user will never see these warnings you can use number instead of constant:
Observer::notify('log_event', 'Something else was done by :username.',
4, 'pluginname');
You could also define the constants yourself. But make sure they are not already defined (Dashboard installed). Defining constants twice will cause warnings.
Download
Download the latest tarball or checkout from GitHub.

July 10th, 2009 at 07:57 PM
He!
very nice plugin, it works like a charm. One remark though:
In the index file when calling DashboardLogEntry you enter the identity and the priority statically so calling the notifier like this:
Observer::notify('log_event', 'Something else was done by :username.', 4, 'pluginname');won’t work. Is this your intention and should the user parse the arguments in himself or did you forget?
July 29th, 2009 at 02:41 PM
You mean :username does not get parsed? Yes it seems I have forgotten that. Will fix. Thanks for the heads up!
August 3rd, 2009 at 01:46 PM
Menno: Back from holidays and had time to check the code. Can you describe what does not work for you? I checked and :username does get parsed before saving. Parsing happens in DashboardLogEntry model.
Your code above works for me.
August 4th, 2009 at 12:38 AM
Having an issue getting this plugin to install on a server where PDO’s are not enabled.
in my frog config.php file i have to set
define(‘USE_PDO’, false);
to make the site work.
After dropping in the plugin when I check the enable box, refresh and select the Dashboard tab I get a blank screen. I tried manually insertiung tables after looking at the install.php, but that didn’t seem to affect anything.
Any ideas or is there an easy way around this?
August 4th, 2009 at 04:53 PM
aeischeid: I do not test without PDO. DoLite emulation (which is used when you do not have native PDO) is quite buggy so I am pretty sure that is causing the errors.
Try enabling debugging to see if PHP spits out any errors.
August 5th, 2009 at 12:31 AM
Fatal error: Class ‘PDO’ not found in /path/to/app/frog/plugins/dashboard/DashboardController.php on line 46
odd thing is that if I set define(‘USE_PDO’, false); on my local ubuntu machine there don’t seem to be any problems
kinda stumped at the moment
August 5th, 2009 at 06:36 PM
After digging through stuff I am almost there. Basically the plugin uses PDO whether it is enabled or not (explains why it still worked on my local machine…), so it is not a bug with DoLite it is merely that you didn’t utilize it. To fix this you would need an extra conditional statements around places where you check for database type.
Before this
if (‘mysql’ == $pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
You would need this
if (USE_PDO) {
An example would be in frog’s index.php
Thanks for a great plugin!
August 7th, 2009 at 11:20 PM
aeischeid: Can you try latest from GitHub?
November 26th, 2009 at 03:39 PM
very good plugin! thanks a lot and keep on…