Welcome Guest, Not a member yet? Register   Sign In
Poll: Improved error logging?
You do not have permission to vote in this poll.
yes
72.73%
24 72.73%
no
15.15%
5 15.15%
maybe
12.12%
4 12.12%
Total 33 vote(s) 100%
* You voted for this item. [Show Results]

Improve Error Logging
#1

(This post was last modified: 04-07-2015, 06:34 AM by ciadmin.)

CodeIgniter should have a better error logging system.
I suggest that error logging should have some options:
1- send error to email (I would like SMTP)
2- save POST, GET, SESSION variables.
3- save URL
4- save user IP address

I think improving error logging is something that should not affect the CodeIgniter performance.

My experience:
Excepting option 2, I used that for better understanding the error.
Because "Trying to get property of non-object ..." does tell me where the error occurred, but it doesn't tell me:
- what user saw that error(maybe the error was in a middle of a function and half a function has run). (option 4)
- maybe that function is used in multiple places (option 3)
- option 1 is to monitor error in real time, and resolving them fast.
Reply
#2

Naaah, I would create a wrapper class (library/plugin) for that and not extend the framework with this functionality. In my opinion, functionality should not be in a framework, well as little as possible. Just keep the framework lean and mean. Everybody has got his own requirements for the log, so ...

And doing it yourself is quite simple. Some quick (and dirty) code:

1.

PHP Code:
function mail_error($errno$errstr$errfile$errline) {
 
 $message "[Error $errno$errstr - Error on line $errline in file $errfile";
 
 error_log($message); // writes the error to the log file
 
 mail('[email protected]''I have an error'$message);
}
set_error_handler('mail_error'E_ALL^E_NOTICE); 

2.

PHP Code:
echo $_SERVER['REQUEST_URI']; 

3.

PHP Code:
var_dump($_POST);
var_dump($_GET);
var_dump($_SESSION); 

of gewoon

PHP Code:
var_dump($_REQUEST); 

4.

PHP Code:
echo $_SERVER['REMOTE_ADDR']; 

Zelf zou ik vragen om een stack dump, maar ook dat is simpel:

PHP Code:
debug_backtrace(); 
Reply
#3

On logging I don't think that are everyone has his own requirements, despite on auth library where everyone would have own requirements.
For exemple on most servers the mail() function is disabled to avoid spam, so you must send through smtp which you must use a library for that.
I couldn't make Email class(from CodeIgniter) to work from Log class and I couldn't extend Log class to intercept all php&db errors.
All I mentioned should be optional, so each user should choose.

Improving error logging is something small and usefull.
I don't like ideas about CodeIgniter having auth library or template library or using composer.
Reply
#4

If anything I think we should have the default "ci logger" and a simple way to bootstrap something like monolog (or any PSR3 interface compatible logger) would be best.
I have already extended log (MY_Log.php) to do this.
When simple logging is needed the standard CI version fine for my work.
Then simply by composering in monolog I can setup a log.php config file switch a setting in config.php and start using it.
Having the CI team write and support 10 different logging methods I feel is overkill.
I would rather have them focus on something else.

I do think we should support all the PSR3 levels in the built in package thou. This way dropping in a PSR3 logger the level would map directly.

DMyers
Reply
#5

A stack trace would be nice with the errors.
Reply
#6

actually it needs a better logging system supports multi output driver(file_system, raven, logstash, xhprof, etc...)
Reply
#7

I think a PSR-3 compatible logger (with an easy way to replace/extend the logger) and some improvements to what is logged internally would be enough. Once you can use any PSR3 logger, you don't really need to worry about supporting all of the different output types, since there are likely already loggers available which do so (or it's relatively simple to develop one if there is not).
Reply
#8

(04-08-2015, 09:13 AM)albertleao Wrote: A stack trace would be nice with the errors.

I think the same, a simple stack trace, at least with the error logging would be a minimum, since nowadays we do not see all the process involved with each issue in the logs.
Reply
#9

I would like some way to override the default logging with external tools like log4php, pear Log or wathever with the ability to keep CI related traces.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB