Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Tracing, Error Logs and Exception Handling

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
TakingSides
Smarty Rookie


Joined: 11 Dec 2010
Posts: 30

PostPosted: Mon Aug 15, 2011 8:16 pm    Post subject: Tracing, Error Logs and Exception Handling Reply with quote

Hi,

I have created my own tracing methods which will write messages to a log file while PHP does not display any on-screen errors.

However, i cannot avoid the Smarty errors which are thrown, annoying the the E_NOTICE errors (which I don't like because it's bad practice)

I have tried setting the smarty error_reporting to 0.
I have created an .htaccess file inside Smarty/ directory with the following:

Code:
php_flag display_errors Off
php_flag error_reporting = 0


Could anyone help me Completely turn off ALL E_NOTICE warnings from smarty so it doesnt trigger my custom error_handler function.

Thanks,
Ash
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Aug 15, 2011 8:28 pm    Post subject: Reply with quote

You can tell Smarty a specific error level for templates:

Code:
$smarty->error_reporting = E_ALL & ~E_NOTICE;


Let me know if that doesn't help get what you want.
Back to top
View user's profile Send private message Visit poster's website
TakingSides
Smarty Rookie


Joined: 11 Dec 2010
Posts: 30

PostPosted: Mon Aug 15, 2011 8:37 pm    Post subject: Reply with quote

Thanks dude,

Technically I don't want Smarty's templates (compiled or otherwise) to throw errors therefore I wanted them turned off. Having said that I do not see a big issue with E_WARNING/E_ERROR since this would suggest something serious has occured.

I do however wish to have full control of logging/tracing errors because I may one day wish to hold a separate log for Smarty errors/exceptions.

I simply added a condition:

Code:
function traceErrors( ... ) {
    if (error_reporting() === 0)
        return false;


Which is registered with....

Code:
set_error_handler('traceErrors');


Anyway, Thanks for your input I overlooked that way Wink

-
Ash
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP