Welcome Guest, Not a member yet? Register   Sign In
Logs class hack

[eluser]Adam K[/eluser]
Hello, today I found out, that in class Logs.php (and in CI as general), info logging has lower priority than debug. Therefore, when I want to log something (as Info), I have to set log_threshold to 3, having logged also 20 debug messages per view.

What I did was to switch log levels in system/libraries/Logs.php (following is excerpt):

class CI_Log {

    var $log_path;
    var $_threshold    = 1;
    var $_date_fmt    = 'Y-m-d H:i:s';
    var $_enabled    = TRUE;
    var $_levels    = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');

Am I the only one, who thinks that info messages should have higher priority than debug messages (After all, CI generates no info messages)? Or am I missing some dead-simple logging system in CI?

Well, Error logs are vital, debug are .... you nkow extremely usefull, but info messages?? are like warnings about that you are using a deprecated function keyword and so..

Adam K,

I do this as well. I wish in the config file you could pipe (|) the threshold so that you could have 1 and 3 on but not 2, or just 2 or just 3.

[eluser]Adam K[/eluser]
@OliverHR - But log_message('info') gives you very powerful option of logging things on smaller sites (so your files don't have million lines...) - if only it didn't save 20+ debug lines to log (on live site it's ridiculous)

@nZac - I think that swapping info and debug is quite okay as hack. I just thought whether it isn't too dirty

It would be nice to have "user" type log message, next to "error", "debug", etc. This way you can extend logging class to email site admin instantly on "error" and add "user" type messages to database, or something like that.

I find myself adding "error" type messages where they're not really errors, but events I'd like to know about when checking application logs.

[eluser]Adam K[/eluser]
@steelaz: That said, I think it would be good for you to switch info/debug logs too. And I so accept with you about that "user" logs.

Adam K

I agree with you about the log levels. I've also added my own Log library in order to make debug the lowest prority. The levels are:

ALL (but this makes no sense as DEBUG would be equal)

INFO is an important level because it can be used to log needed actions from users.
Debug would be exclusively for development and info important for production use.

Is there a posibility that CI implements this log level instead of the confusing current one?

Theme © iAndrew 2016 - Forum software by © MyBB