0

I have set error level to 1 in config.php. But the problem is that i am getting many errors that is NOT ACTUALLY ERRORS in terms of application logic.

Consider the following code examples

  $deleted = @unlink($filename);

  $imap_uid = @imap_uid($con,$msgno);

As you can see that the above example will not throw errors, but codeigniter will log if an error occurred.

Is it possible to disable error logging dynamically ?

i am expecting something like this

 // ....

   $this->error_log = 0; // disable error logging

   //Perform some operation that which may log an error,even its suppressed 

   $this->error_log = 1; //enable it again

 // ...

Thanks.

2 Answers 2

1

You can extend CI_Log class adding setters for $_enabled

Class MY_Log extends CI_Log
{
    function enable_logging($item=TRUE) {
         $this->_enabled = (bool)$item;
    }
}

Now you can do like this

$this->log->enable_logging(FALSE);//Disable

$this->log->enable_logging();//Enable

Sign up to request clarification or add additional context in comments.

Comments

0

Thanks based on Michail's answer i have this more flexible solution using the protected $_threshold variable.

Class MY_Log extends CI_Log
{
  public function setThreshold($l){
    if(!in_array($l,array(0,1,2,3,4,5))){
      log_message("error","MY_Log->setThreshold unsupported val: " . $l );
      return false;
    }
    $this->_threshold = $l;
    return true;
  }
}

And from your controller you do

$this->log->setThreshold(0);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.