CodeIgniter Forums
Logs class hack - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Logs class hack (/showthread.php?tid=29432)



Logs class hack - El Forum - 04-09-2010

[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):

Code:
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?


Logs class hack - El Forum - 04-09-2010

[eluser]OliverHR[/eluser]
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..


Logs class hack - El Forum - 04-09-2010

[eluser]nZac[/eluser]
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.


Logs class hack - El Forum - 04-10-2010

[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


Logs class hack - El Forum - 04-10-2010

[eluser]steelaz[/eluser]
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.


Logs class hack - El Forum - 04-10-2010

[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.


Logs class hack - El Forum - 06-21-2010

[eluser]Unknown[/eluser]
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:

DISABLED
ERROR
INFO
DEBUG
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?