Welcome Guest, Not a member yet? Register   Sign In
Logging broken?
#1

[eluser]beatryder[/eluser]
The logging system seems broken to me:

Quote:| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages

I have
Code:
$config['log_threshold'] = 3;

And I expect to only see "info" level messages, but instead I am seeing everything, debug messages, info and error messages.

The same goes if I use level 2, I not only see DEBUG but ERROR as well.

Perhaps I don't understand the design idea here, but it seems to me that the order should be:

| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Informational Messages
| 3 = Debug Messages
| 4 = All Messages


Furthermore, level 4 is totally redundant. Since level 3 does the same thing.


Am I crazy?


Also note that I am using code like

Code:
log_message('debug','Something happened here');

with level 3 set and I am still seeing DEBUG and ERROR Messages, which is not what I expect to see.
#2

[eluser]jabbett[/eluser]
CodeIgniter's logging design is consistent with loggers across the programming world. Basically, you have a series of increasing severities... in CI's case: informational (least important), debug (more important), error (most important). When you set your log threshold, you're choosing to see everything at that level or more important, not only that level. So, if you choose DEBUG, you'll see all error messages with levels >= DEBUG.

Note that, in other logging systems, it's more typical for the INFO level to be more important than DEBUG. Not sure why CI chose to invert the order.
#3

[eluser]beatryder[/eluser]
[quote author="jabbett" date="1194301895"]... So, if you choose DEBUG, you'll see all error messages with levels >= DEBUG.[/quote]

Okay, but that still seems broken to me. If I want INFO messages logged, then I get all debug and errors at the same time? That seems a little strange to me.
#4

[eluser]Seppo[/eluser]
I agree with beatryder... what's the point of having level 3 & 4 if both log the same levels?

Edit: also, would be great to be able to enable/disable different error levels
#5

[eluser]beatryder[/eluser]
[quote author="Seppo" date="1194309991"]...also, would be great to be able to enable/disable different error levels[/quote]

That was where I was going with this whole thing. Most other logging facilities binary flags to set the error level, so you might find:

1 - Error
2 - Debug
4 - Info
8 - PHP Error

so if you set the log level to 4 you would only get INFO, but if you used 3 you would get Error and Debug.
#6

[eluser]jabbett[/eluser]
I see how binary flags would make everything more flexible, but I've never been in a situation where I didn't want to capture messages that were more important than my threshold, e.g. if I'm capturing INFO, then I'd certainly want to report ERROR as well. Because I expect my threshold to work as such, I categorize log messages to take advantage of the built-in hierarchy.

Maybe a log viewer that allows custom filtering is the right solution?
#7

[eluser]beatryder[/eluser]
[quote author="jabbett" date="1194311279"]Maybe a log viewer that allows custom filtering is the right solution?[/quote]

A log viewer works, I am proficient with grep and awk so it doesn't take a lot for me to parse the logs. The issue I have is that I do not want the files getting too big.
#8

[eluser]jabbett[/eluser]
Taking another look at what CodeIgniter is putting in my log file, I see what you mean about file size. I think the problem is really that all the very low level messages CI generates...

DEBUG - 2007-11-05 11:48:27 --> Config Class Initialized
DEBUG - 2007-11-05 11:48:27 --> Hooks Class Initialized
DEBUG - 2007-11-05 11:48:27 --> Router Class Initialized

should be at the lowest level (CI's "informational") rather than the mid-level (CI's "debug"). I'd like my own log messages to appear in two levels, but they should both be "above" the CI debug nonsense.
#9

[eluser]beatryder[/eluser]
Well hopefully this post will get the attention of Derek or one of the other devs. Then maybe they can answer our questions.




Theme © iAndrew 2016 - Forum software by © MyBB