soumavachakraborty / gaforflash

Automatically exported from code.google.com/p/gaforflash
Apache License 2.0
0 stars 0 forks source link

isolate the debug #57

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
make an external debug.swf that we inject at runtime for debugging if needed

goal:
* optimize the ga code
* earn 10KB in footprint

Original issue reported on code.google.com by zwetan on 18 Nov 2009 at 10:15

GoogleCodeExporter commented 8 years ago
visualdebug or debug was a quick hack and now it have to go

this will remove
  * DebugConfiguration class
  * the whole package com.google.analytics.debug

Instead we will use the logd library
http://code.google.com/p/maashaack/wiki/logd

and conditional compilation
http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html

LOG::P will be used to include or not the logging

gaforflash.swc will not include any debug (and should earn 10KB in footprint)

gaforflash_d.swc will include extensive logging

We will not inject at runtime a debug.swf
as this would not work for every scenario
(cross-domain problem, AIR mobile, etc.)

Original comment by zwetan on 15 Apr 2012 at 11:25

GoogleCodeExporter commented 8 years ago
logd is small, fast, have no dependencies and is customisable

eg. even if you don't like the library
you can add "hooks" or "addons" to redirect the logging
to your own library or any other logging library
(SOS console, as3-commons-logging, firebug, MonsterDebuger, etc.)

We will provide examples and addons
to show users how to customise logd.

Also as a separate project, we will provide
a custom logger interface for gaforflash.

Original comment by zwetan on 15 Apr 2012 at 11:31

GoogleCodeExporter commented 8 years ago
here a simple example

before
----
        public function trackPageview(pageURL:String=""):void
        {
            _debug.info( "trackPageview( " + pageURL + " )" );
            _call( "_trackPageview", pageURL );
        }
----

after
----
private var _log:Logger;
----
        public function trackPageview(pageURL:String=""):void
        {
            LOG::P{ _log.v( "trackPageview( " + pageURL + " )" ); }

            _call( "_trackPageview", pageURL );
        }
----

Logger is an interface, importing it should have very few impact
on the final library size (really few bytes)

every log call is placed within a conditional compilation tag LOG::P
that means if you do not enable it, nothing is added to the source code
(really ZERO bytes)

even if you import "core.log" (at worst add max 1KB to the library)
but you only call it within the CC tag, then the class should not be
added to the final binary

pros:
  - we should earn at minimum 10KB on the library
     (the size of the visual debug package)
  - any logging call, wether they add few KB or 10MB etc.
     will add exactly ZERO bytes to the final library (eg. non-debug)
  - even if you use the debug SWC, logs can be disabled
    and should not add much more KB to the final SWF or AIR
  - you can customise it with any other logging library

cons
  - we impose logd library on you, you can not change that
  - using conditional compilation prevent to use Flash CS3
     with the sources of gaforflash (but you can still use the SWC)
  - by default the logging is very minimalist
     if you can see trace() statement you will see logd traces, but that's it

Original comment by zwetan on 15 Apr 2012 at 11:48

GoogleCodeExporter commented 8 years ago
done
now adding gaforflash.swc to a project add only 35KB

Original comment by zwetan on 30 Apr 2012 at 10:07