Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Logging inside of PureMVC - Where to place it?  (Read 9717 times)
mikerichmond
Newbie
*
Posts: 1


View Profile Email
« 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #2 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.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Pages: [1]
Print