On 04.10.2008, at 08:16, Yves Räber wrote:
I want to implement something really simple : log some events into a
database. And I already can think of three way to do it, but because
this will be used very frequently I'd like to know what's the best
solution. For me the best solution would be to have little overhead, and
a really short command (like $c->logdb()).

When deciding where to put things (model vs. controller) I always imagine what would happen if I took the Catalyst part away. In most cases the model should be able to fulfill everything without Catalyst being involved (for instance, if you'd like to use your model from a cronjob script). Thus, in this case, I'd definitely put the logging into the model to have it log everything even when Catalyst is not involved. I assume that every logging action goes together with a create/update/delete of model objects and is rarely triggered alone. If that's the case, have you thought about overriding the create, update, delete methods DBIC provides to add the logging there? That way you'd have to do it only once and every (write) action on your model is automatically logged.

--Tobias


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to