On Thu, Sep 10, 2009 at 6:43 AM, Jens Schwarz <blacky6...@gmx.de> wrote:
> Oh, *err* right. I meant 'logging' and not 'protocol' *douh*. > > Well, right now I have a proto^Wlogging action in my Root controller that I > call everytime I want something to be logged in my DB. > P.ex.: > > package MyApp::Controller::Book; > (...) > sub create ... { > ... > $c->forward("MyApp::Controller::Root","myLoggingAction",["some message that > should be logged"]); > } > > In addition to this, I have a logging controller, that simply displays the > list of logged messages from the DB. > > Think of something like: > > | Timestamp | User | Action | > +------------------+--------+------------------+ > | 2009-09-10 10:30 | foobar | created new book | > > So the question is: Is there a neater way of doing this? Some kind of best > practice? > > Hi Jens, I would do one of two things. The first is to build a custom Catalyst::Log class if that is what you are looking for, or you could even just use Catalyst::Log::Log4perl and configure it as necessary. (Using Catalyst::Log::Log4perl is what I would use). Then, simply use $c->log->whatever. The other option is to create a model for this, and change the code to: $c->model('Logger')->log("Message"); If you use the model approach, you can use Catalyst::Component::ACCEPT_CONTEXT to access $c->model('Schema') and $c->user. -J
_______________________________________________ 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/