PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: mikerichmond on October 26, 2007, 07:40:03



Title: Logging inside of PureMVC - Where to place it?
Post by: mikerichmond on October 26, 2007, 07:40:03
I was wondering where the best place to put "logging" code would be inside of the PureMVC framework?  To clarify "logging", I mean a class that listens for events and then communicates with a remote server to log this event.  A good example is code that keeps track of user statistics (i.e. how many users performed a specific action inside of the app).


Since it involves data and communication with a remote server I thought a proxy would be a good place... but they can't receive notifications, so they're out.

A mediator could work, but it wouldn't be managing a view component so it seems to break the philosophy behind PureMVC.

Commands work but I'm running into some limitations there as well.  Since only a single command can be registered to a given notification, this requires me to place code inside of other commands that should be unrelated (i.e. if I wanted to "log" applicaiton startup, then I need to place code inside the command that currently initializes the components).  Also, since commands do not specify which notifications they want to respond to, that means placing more code in an unrelated class (typically ApplicatonFacade).  Yet another problem with commands is what happens if I wanted an additional logger that wanted to respond to the same Notification as another logger (i.e. if one wrote info to a db for archiving purposes, and another one wrote info to a db to compile usage statistics), then I would need to have a MacroCommand that called two separate SimpleCommands.... this makes maintainability an issue.


Any thoughts?


Thanks,

Mike


Title: Re: Logging inside of PureMVC - Where to place it?
Post by: puremvc on October 26, 2007, 10:28:25
A good way might be to override notifiyObservers in your Facade, and have it call a method on a LoggingProxy, which passes the Notification info to a service. It might maintain a lookupTable of which notification to pass to which service in the case that  you have multiple server-side logging destinations.

-=Cliff>


Title: Re: Logging inside of PureMVC - Where to place it?
Post by: Joel Hooks on December 20, 2007, 11:53:29
I created a LogEventCommand that recieves notifications and activates the LogEventProxy which communicates with the server and logs the users actions.