Welcome Guest, Not a member yet? Register   Sign In
Logging levels

[eluser]louis w[/eluser]
I kind of feel there should be an logging level between error and debug. I almost even think that informational messages should be above debug.

Error message are.... errors.
Debug messages you would only use during development.

I want something between those, for instance when a user does a certain action like delete an item or such. I would want to record this. I could care less about what classes are instantiated once a site is in production. But with informational messages being below debug messages there is nothing I can do about it.

I am extending the error class to allow for sending them to syslog instead of text files. Might have to hack it up a bit to allow for this change in levels.

I normally just use log_message(...) in the code, like the bit of code that deletes a user, then I would set a log_message at either debug or info level...

[eluser]louis w[/eluser]
In order for informational message to be logged I would have to set a log level of 3. This is also activate debug messages (level 2) from being logged.

Debug message (e.g. Model Class Initialized) are the ones that fill up the logs and are only useful on a development environment.

This is my argument as to why informational message should be ranked higher then debug. I could see many instances where people might want to log info and not debug.

Ah, yes, I see what you mean. My misunderstanding. We need a 1.5 setting Smile

I felt the same problem; I really cannot understand why in CI the level INFO is below DEBUG when the well-known log levels are:

FATAL (something horrible happens)
ERROR (something wrong happens)
INFO (something important happens)
DEBUG (development purpose)
TRACE (one more development level)

Anyway I extended Log library into MY_Log in application/libraries just switching INFO and DEBUG levels (you can add more if you wish).
Here's the code:

class MY_log extends CI_Log {

   //INFO and DEBUG have been switched.
   var $_levels    = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');

I wonder if it is possible to log only ERROR and INFO?
At the moment I set my log level to 1 and mark all 'INFOmations' as 'ERROR'.. Undecided

[eluser]louis w[/eluser]
fustaki: This would work, and is similar to what I had to do to get it to work. I would still like a more integrated solution if possible.

rockacola, This is exactly my point. At the moment you can't.

Could we get an official Ellis Lab reply to this topic?

What about the possibility of letting log_level be an array (but also work as a string).

Well, I've been hit by this just now. In every logging system I've known, "DEBUG" level is the most verbose, INFO should definitely come between ERROR and DEBUG

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

Compare, for example with Log4J: http://logging.apache.org/log4j/1.2/manual.html


The standard strategy is to set level=DEBUG in development, and from ERROR to INFO in production. In particular, I want to turn on INFO messages in production, sort of an informal account of relevant events (not errors), but I cannot do that without including the tons of DEBUG messages that generates the core system. This is unreasonable.

Theme © iAndrew 2016 - Forum software by © MyBB