Welcome Guest, Not a member yet? Register   Sign In
Writing to File in log directory from custom library
#1

[eluser]NotoriousWebmaster[/eluser]
Hi all:

Just learning CI on a legacy system.

I'm interested in porting my log class to CI as a library. How do I specify writing to a file in the log directory?

Thanks for your help,
- AAA
#2

[eluser]bubbafoley[/eluser]
is this what you are looking for?

Code:
$ci = get_instance();
$log_path = ($ci->config->item('log_path') != '') ? $ci->config->item('log_path') : APPPATH.'logs/';
$fp = fopen($log_path.'custom_log.php', FOPEN_WRITE_CREATE);
fwrite($fp, 'your log message here');
fclose($fp);
#3

[eluser]NotoriousWebmaster[/eluser]
Update: Let's hold off on this. I took out references to Aalog, and still got the error. So it's outside of my code... News at 11.

Thanks bubbafoley, it may very well be; but I can't even get to my library. Here's the code I have in the controller:

Code:
$this->load->library('aalog', array('logName' => 'ccsr.log'));

And here's the error I get:

Quote:Fatal error: Class 'CI_Log' not found in C:\_sites\ccsr\system\codeigniter\Common.php on line 148

I have a file called Aalog.php in system\application\libraries. (This is also a source of concern for me: isn't application supposed to be outside of system; a sibling in fact?)

Thanks again for your help. (Looking forward to shedding my Summer Student status. Wink )




Theme © iAndrew 2016 - Forum software by © MyBB