Display errors OpenCart

谁都会走 提交于 2019-12-11 00:51:39

问题


In PrestaShop I can display the errors with the function Tools::displayError() like this:

if (empty($email)) {
        $this->errors[] = Tools::displayError('Email is empty.');
        $this->doLog('ERROR: Email/username is empty');
    } elseif (!Validate::isEmail($email)) {
        $this->errors[] = Tools::displayError('Invalid email address.');
        $this->doLog('ERROR: Invalid Email address');
    }

Is there a similar way to do this in OpenCart? Is there a function i can use?

Thanks


回答1:


To Turn on error reporting, please follow :

  • Go To Admin Panel

  • Go to System > Settings

  • Select your store from the list and click Edit

  • Go to the Server tab

  • To display errors, change Display Errors to Yes, If you want to log errors to a file, select Yes for Log Errors

  • Enter in an Error Log Filename

  • Click Save

Print Custom error message inside error.log

$logger = new Log('error.log'); //just pass the file name as error.log
$logger->write('Custom Error Message');

You will see the error file inside system-> storage-> logs-> error.log



来源:https://stackoverflow.com/questions/43340726/display-errors-opencart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!