Archives
- March 2010 (1)
- February 2010 (1)
- January 2010 (2)
- December 2009 (1)
- November 2009 (2)
- October 2009 (5)
- September 2009 (1)
- March 2009 (3)
- February 2009 (1)
- January 2009 (2)
- October 2008 (1)
- September 2008 (5)
- July 2008 (1)
- June 2008 (5)
- March 2008 (1)
- January 2008 (1)
- December 2007 (5)
- November 2007 (8)
Categories
Blogroll
-
kurokikaze
-
Richard Bradshaw
-
johannilsson
-
tweetrider
-
Richard Bradshaw
-
Tim
-
me
-
Jens Schauder
-
Jens Schauder
-
xrado
-
Dominik Jungowski
-
Richard Bradshaw
-
Dominik Jungowski
How to use Twitter as an error log
Sure this has been done before, but I had a brainwave today – why not use Twitter as an error log for web apps?
I already have error handling on my functions, so surely this shouldn’t be a difficult addition… turns out it’s not.
First, you’ll need a twitter account. I’d recommend setting one up, then protecting the updates. Keep the username and password, you’ll need them in a minute. I’d then follow the new account you set up, as well as anyone else on your team.
Then, define a function as follows in PHP, preferably in a global include or some such thing.
My function here takes two parameters, the error code as well as a description. You could generalise this and rejig it a bit, as well as perhaps changing the $status variable to look different.
For instance,
or
to send it to you. You could even define different usernames for different types of errors, if you are in a team.
In your code, then call it like this:
to log a 404, as well as the page it came from, or:
In your database connection script, or even:
in your comment/email form handling.
Hope this comes in useful!
Random Posts