Log/Logging to different files - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Log/Logging to different files (/showthread.php?tid=25933) |
Log/Logging to different files - El Forum - 12-31-2009 [eluser]Unknown[/eluser] Hi all, I just tweaked the logging code so that I could log to an arbitrary files. I know its not wise to change the core code but this was too minor to write a separate Log library or extend the core Log library. I am posting the code hoping it might be useful for someone. ----------- Code Changes -------------- system/codeigniter/Common.php line 241 Add $filepath to the function definition Code: function log_message($level = 'error', $message, $php_error = FALSE, [b]$filepath[/b]) system/libraries/Log.php line 75 Add $filepath to the function definition Code: function write_log($level = 'error', $msg, $php_error = FALSE, [b]$filepath[/b]) inside this function on line 98 replace this code with Code: $filepath = $this->log_path.'log-'.date('Y-m-d').EXT; Code: if(empty($filepath)) ------- Usage --------- Normally we use log_message('error', " msg to log ") ; You can optionally use now log_message('error', " msg to log", '', 'app' ) ; The later will be logged to some file like app-2009-12-31.php the log directory. --------------- Derek, It would be great if you can accomodate this small modification in the coming releases. regds, Shikhar Log/Logging to different files - El Forum - 06-06-2013 [eluser]Unknown[/eluser] Hi, I was trying to tweak this to pass additional parameters to log. Code: function log_message($level = 'error', $message, $php_error = FALSE, $arguments = array()) This doesn't work. I tried printing $arguments and I always get empty array (Even if I'm passing the argument). What is the role of Code: [b] and [\b] |