theillo Posted March 8, 2015 Share Posted March 8, 2015 In back office, under "Advanced Parameters" there's a LOGS tab. Also there is a email template, called "log_alert" which has the text "WARNING: you have received a new log alert in your Back Office." in it. And there is abstract class AbstractLoggerCore under "classes/log/AbstractLogger.php" And I see quite a few messages getting logged, but I could not find out how to log one myself. I'd like to record a warning and notify the store admin, if something goes wrong in the module I am creating. Anybody has a good idea how to do this? Link to comment Share on other sites More sharing options...
bellini13 Posted March 8, 2015 Share Posted March 8, 2015 yes, it is very simple. For a good example, open the PaymentModule class and search for "PrestaShopLogger::addLog". Just realize this class and function will only work with PS v1.6. In PS v1.4 and v1.5, the class name is Logger. and it does not exist in v1.4.0.3 or earlier. 1 Link to comment Share on other sites More sharing options...
theillo Posted March 19, 2015 Author Share Posted March 19, 2015 Great, thanks! To test it I just called it in the constructor of one of my admin controllers. It worked once, no matter how many time I reload the page... We'll see. So in classes/PrestaShopLogger.php we have public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false, $id_employee = null) This method makes a call to sendByMail($log), which will first check if we have email logs turned on. if (intval(Configuration::get('PS_LOGS_BY_EMAIL')) <= intval($log->severity)) Anybody know if there's an interface in back office where PS_LOGS_BY_EMAIL get's set? Of course I could just turn it on before logging the alert if I insist on an email being sent, but that seems improper. Link to comment Share on other sites More sharing options...
bellini13 Posted March 19, 2015 Share Posted March 19, 2015 Yes, it is in the Logs page Link to comment Share on other sites More sharing options...
theillo Posted March 19, 2015 Author Share Posted March 19, 2015 Whoops, I guess I am blind... I was looking for it this morning, but didn't see it. Got it this time. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now