Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Change log level at runtime
#1

[eluser]Unknown[/eluser]
Hello,

I want to change the log level to a value read from the database. I try
Code:
$this->config->set_item('log_treshold', $value);
but it doesnt work.
Code:
echo $this->config->item('log_treshold')
reports the new value but CI ignores it.

Do I something wrong? Can someone help me?

Best regards,
Thomas

Edit:
After some more tests it seems that only log level 0 is working. If the log_treshold is set to 0 there is no more logging. It is set to any other number CI logs all levels.
#2

[eluser]InsiteFX[/eluser]
This is because CodeIgniter controls the logging.

See Log.php

CodeIgniter sets the value when it loads the Log.php

So any changes you made will not take affect.

You might be able to extend the Log.php library.

InsiteFX
#3

[eluser]Unknown[/eluser]
I figured it out:
Code:
$this->config->set_item('log_threshold', $level);

$LOG =& load_class('Log');
$LOG->CI_Log();  // call constructor to reread the config
You must set the new trashold in the config and then call the constructor from the LOG object to reread the value from the config object.

Thanks InsiteFX for the clue with the LOG class.

Best regards,
Thomas
#4

[eluser]John_Betong[/eluser]
I would have tried using a $_SESSION variable...

// ./config/config.php
Code:
$_SESSION['my_threshold'] = isset($_SESSION['my_threshold']) ? $_SESSION['my_threshold'] : '0';

  $config['log_threshold'] = $_SESSION['my_threshold'];

 
 
 
#5

[eluser]Unknown[/eluser]
I tried this solution but I didn't have any success. Any other thoughts?

[quote author="Thomas Henkel" date="1296029538"]I figured it out:
Code:
$this->config->set_item('log_threshold', $level);

$LOG =& load_class('Log');
$LOG->CI_Log();  // call constructor to reread the config
You must set the new trashold in the config and then call the constructor from the LOG object to reread the value from the config object.

Thanks InsiteFX for the clue with the LOG class.

Best regards,
Thomas[/quote]




Theme © iAndrew 2016 - Forum software by © MyBB