bpz Posted December 19, 2011 Share Posted December 19, 2011 Hi, First off, thank you developers for this beautiful framework. I love it. 2 questions: Is there a processwire function to log custom messages? Database or file. I'd like to use it for noncritical errors. What is the processwirish way to deal with critical errors? Now I just throw an Exception() (gets caught). Thanks! Link to comment Share on other sites More sharing options...
ryan Posted December 19, 2011 Share Posted December 19, 2011 Is there a processwire function to log custom messages? Database or file. I'd like to use it for noncritical errors. bpz, welcome to the forums. Good question. You'll want to use the FileLog class: <?php $log = new FileLog($config->paths->logs, 'your-log-name'); $log->save("Your log message goes here"); In 'your-log-name', leave off an extension as it automatically adds a .txt extension. You'll find your log file in /site/assets/logs/. What is the processwirish way to deal with critical errors? Now I just throw an Exception() (gets caught). Throwing an exception is what you'd want to do if the error is fatal and you want execution to stop. It's preferable to throw a WireException rather than a normal Exception. Pass the error message to the exception. i.e. throw new WireException("your error message here"); Here are the most common exception classes in PW: WirePermissionException – what to throw when access denied and execution should stop Wire404Exception – what to throw when resource doesn't exist and 404 page should appear WireException – any other fatal error Link to comment Share on other sites More sharing options...
bpz Posted December 19, 2011 Author Share Posted December 19, 2011 Thank you for your quick reply, I will look into it. And when I get the project done, I will let you know via PM - you'll see how cool your framework is ha! Link to comment Share on other sites More sharing options...
Soma Posted December 19, 2011 Share Posted December 19, 2011 ... let us know via public post Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 19, 2011 Share Posted December 19, 2011 And if you want to manage (see/clear) your logs in the backend you can use my this module: http://processwire.com/talk/index.php/topic,738.0.html 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