![]() |
CodeIgniter Logging - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: CodeIgniter Logging (/showthread.php?tid=27818) |
CodeIgniter Logging - El Forum - 02-21-2010 [eluser]falkencreative[/eluser] Hello all. I've recently started using CodeIgniter, and like a lot of beginners (I imagine) I'm starting by writing a basic application. Basically, the site is split into two sections -- a client frontend where clients can log in and view pages specific to them, and an admin section for admin users to login and manage clients, client information, etc. I'm looking to develop something that will keep track of recent actions by the admin. For example, I would keep a log of actions such as adding new clients, updating client information, uploading files, etc. Ideally, I will create some sort of function that will be accessible to all controllers, something along the lines of: log($logType, $logMessage); that would take the input and log it in the database. Where would be the best place to put this code? Create a library and place it within the libraries folder? Create a controller for this? (I'm not sure how that would work -- I don't think that is the right way to go). Add it to the helper functions? I'd appreciate any comments or links to applicable websites. CodeIgniter Logging - El Forum - 02-21-2010 [eluser]heavenquake[/eluser] In MVC generally and CodeIgniter specifically you communicate with the database through models. I would write a model and place it in the models folder. Then I would do: Code: $this->load->model('logs'); when I need to save stuff and Code: $this->load->model('logs'); When I need to view stuff. the code for the model would be like this: Code: class Logs extends Model { Have a look at the userguide pages on models ( http://ellislab.com/codeigniter/user-guide/general/models.html ) and database access ( http://ellislab.com/codeigniter/user-guide/database/index.html ) for more info CodeIgniter Logging - El Forum - 02-22-2010 [eluser]falkencreative[/eluser] Thanks -- I appreciate the reply. |