tag:robotlegs.tenderapp.com,2009-10-18:/discussions/suggestions/28-robotlegs-should-support-loggingRobotlegs: Discussion 2018-10-18T16:35:14Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T13:34:42Z2010-07-15T13:34:42ZRobotLegs should support logging<div><p>Internal logging was removed from Robotlegs v0.9 due to size and
performance issues (we wanted it to be as small and fast as
possible, with minimal external dependencies). What kind of things
would you like to see logged?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T13:39:11Z2010-07-15T13:39:11ZRobotLegs should support logging<div><p>Hi Borek,</p>
<p>There isn't one that I know of, but it's not going to be hard
for you to implement using the src package.</p>
<p>The base/mvcs package classes are a concrete implementation of
robotlegs - like trousers that the robotlegs wear. Don't feel too
afraid of poking around in them, they're pretty easy to follow.</p>
<p>If you wanted to log all events then I'd recommend adding this
to the EventMap/CommandMap classes in the base package. Initially
you could just hack it directly in there - essentially you'd just
be adding to the callback function with some sort of logging action
- whether that's just triggering an additional LogEvent on that map
(be careful of infinite recursion possibilities there) or maybe
doing something clever with signals (seems like a good use case for
that).</p>
<p>Once you've got it working how you'd like it to, you can break
this out into utility classes instead:</p>
<p>LoggingEventMap</p>
<p>and</p>
<p>LoggingCommandMap</p>
<p>for example.</p>
<p>In the mvcs package, you'll see that Mediator creates its own
event map, and Context creates a command map.</p>
<p>Simple extend those: LoggingMediator and LoggingContext so that
they also contain / provide a loggingEventMap /
loggingCommandMap</p>
<p>When you're done, post your code on github and it can be a
useful utility (usually requires unit tests along side code to
allow others to refactor / extend).</p>
<p>Personally I think actual logging of all events is overkill but
I'm building big apps - so I have a LogEvent wrapper that logs the
event and then fires the event itself. When I just need to follow
what's going on I just hack traces into the EventMap / CommandMap.
This is more useful than tracing in the constructor of the event
itself because when robotlegs clones the events the multiple traces
can be hard to follow.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T13:52:02Z2010-07-16T09:27:28ZRobotLegs should support logging<div><p>Shaun, I'm starting with RL so I'd sometimes appreciate insight
into the general flow of my program.</p>
<p>Stray, thanks for the tips. I'll keep them in mind for the
future.</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T13:57:19Z2010-07-15T13:57:19ZRobotLegs should support logging<div><p>Perhaps we could think about using conditional compilation to
include logging for "debug" builds.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T14:02:28Z2010-07-16T09:27:28ZRobotLegs should support logging<div><p>That would be great!</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T14:16:47Z2010-07-15T14:16:47ZRobotLegs should support logging<div><p>That's a really nice idea.</p>
<p>I've always found that conditional compilation throws a wobbly
if I don't include the variable in my compiler vars, so would this
require an extra compiler var whether you're using it or not?</p>
<p>What do people want the mechanism to be? I'm guessing plain
events... how did you do it before? (I can go back through the
archives to 0.9 I guess).</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T14:22:20Z2010-07-15T14:22:20ZRobotLegs should support logging<div><p>Oh no, I'd don't like the sound of wobblies! To be honest, I
haven't played with conditional compilation in AS3 yet, so will
have to see how that pans out.</p>
<p>We used to do the logging through the as3commons logger:</p>
<p><a href=
"http://www.as3commons.org/as3-commons-logging/index.html">http://www.as3commons.org/as3-commons-logging/index.html</a></p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T14:51:02Z2010-07-15T14:51:02ZRobotLegs should support logging<div><p>I think this is great use for conditional compilation and I'd
definitely support this feature (though not a big priority). For
those who directly use the swc it shouldn't throw wobblies. For
those who use the source code, I don't think it'll be too big of a
challenge. Conditional compilation is becoming more mainstream and
more and more developers have run into the wobbly and are
comfortable with it. For example, TLF uses multiple conditionals
("debug" and "release")--not saying we should use TLF as our
model.</p></div>Aaron Hardytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T18:24:05Z2015-10-19T23:47:52ZRobotLegs should support logging<div><p>I have been playing with conditional compilation the last couple
of days actually.</p>
<p>It works great however the IDE has a big part in making it easy
to use. For example we use Flash Builder at work and you can easily
add additional command line params in your project properties. The
problem is when you want to do a release build you have to remember
to disable your "debug" command line as there is no separate
setting for release mode command line args.</p>
<p>Also conditional name spaces arent picked up by the type
hinting. So type "CONFIG::" then cmd + space and you get
nothing.</p>
<p>This is all just fluff tho and if you use another IDE such as
Flash Develop there are plugins to assist you.</p></div>mike.canntag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T18:33:49Z2010-07-15T18:33:49ZRobotLegs should support logging<div><p>It's easy in project sprouts ;)</p>
<p>The only reservation I have is that you can't set this in the
swc (as you wouldn't be able to switch it back and forth), so it
would mean people having to add another command line param (as far
as I'm concerned nothing is easy in Flash Builder!).</p>
<p>The Flash IDE allows conditional compiling params, so that's not
a problem - existing workarounds would continue to work.</p>
<p>It's just <em>another</em> step in getting going with RL though.
If you have CONFIG::UseLogging or whatever, it's not possible to
get going without this variable set.</p>
<p>So - the balance is whether the extra step to get going at all
is worth it for an extra feature once you do get going... or
whether this should be outside of the basic set up, but easy to
implement with a how-to or even a utility?</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:31:18Z2010-07-15T19:31:18ZRobotLegs should support logging<div><p>Stray, if I understand your statement, I don't think it's
accurate. You set the conditional compilation argument on the
library project and the swc gets compiled with that conditional
compilation. Once the swc is built, the app that uses the swc need
not define the argument. At that point, the conditional argument
can't be switched back and forth.</p>
<p>In other words, we'd leave the debug argument to false for the
swc and it would require no configuration on the part of the
developer using the swc. If they want to enable debugging, they'd
check out the source and switch the argument value on the RL
library.</p></div>Aaron Hardytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:35:54Z2010-07-15T19:35:54ZRobotLegs should support logging<div><p>I might clarify that, yes, that would be an extra step for
anyone wanting to use the RL source (not swc).</p></div>Aaron Hardytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:36:41Z2015-10-19T23:47:52ZRobotLegs should support logging<div><p>Or have two SWCs one with debug in one without...</p></div>mike.canntag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:42:20Z2010-07-15T19:42:20ZRobotLegs should support logging<div><p>Hi Aaron - that's exactly what I was saying. (Or intending
to).</p>
<p>The swc argument is fixed. So - if you want to use logging you'd
have to use source and set the CONFIG parameter yourself in the
compiler vars.</p>
<p>So - unlike the usefulness of putting the keep_as3_metadata
config params in the swc - because they never change - you'd be
stuck with an argument which might not meet your requirements.</p>
<p>On the other hand, if we don't include it in the swc then you
can't compile at all until you've set it one way or the other
(that's my experience of forgetting to set a compiler var
anyway).</p>
<p>Not sure where I was unclear but obviously I was.</p>
<p>My thought is that if it's not going to work out-of-the-box then
it's as well being a utility perhaps?</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:44:15Z2010-07-15T19:44:15ZRobotLegs should support logging<div><p>What do people feel about that?</p>
<p>On instinct I don't like having 2 libraries with the same code /
name etc, 2 assets to keep track of etc, but then I don't use swc
unless there's no src available.</p>
<p>So - swc lovers, is having 2 swc files ok?</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-15T19:50:58Z2010-07-15T19:50:58ZRobotLegs should support logging<div><p>Sorry about that then. We're on the same page.</p>
<p>Personally I'm not keen on the idea of two swcs. I'd be up for
having a conditional arg on the library that's default debug=false
and if people want to use debug they check out the code and set the
arg to true. Or, if all the necessary hooks are available, I think
a debug add-on is probably the best option.</p></div>Aaron Hardytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-16T09:36:49Z2010-07-16T09:36:49ZRobotLegs should support logging<div><p>Before we focus on conditional compilation too much, is really
having a couple of myLogger.info() method calls causing performance
issues? It may be slow to log to some targets like file system log
files but having these method calls in the source code and not
using them in production can't harm performance too much can
it?</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-16T14:15:32Z2010-07-16T14:15:32ZRobotLegs should support logging<div><p>It's not just a matter of speed - filesize and external
dependencies play a part too.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-19T07:07:19Z2010-07-19T07:07:19ZRobotLegs should support logging<div><p>Logging API is part of the Flex framework and would require no
external dependencies (I understand that there could have been
issues with some 3rd party logging library but I don't see many
reasons to avoid native Flex logging in this case).</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-19T07:22:08Z2010-07-19T07:22:08ZRobotLegs should support logging<div><p>No external dependencies other than the Flex framework.
Robotlegs isn't<br>
dependent on Flex.</p></div>Tim Oxleytag:robotlegs.tenderapp.com,2009-10-18:Comment/22668952010-07-19T07:29:40Z2010-07-19T07:29:40ZRobotLegs should support logging<div><p>True, I forgot about that... It would be a big dependency then
:)</p></div>borekb