home *** CD-ROM | disk | FTP | other *** search
/ T-Online 6 / T-Online.iso / Animation / content / intro / intro.swf / scripts / __Packages / application / debug / Logging.as
Encoding:
Text File  |  2005-10-20  |  2.9 KB  |  115 lines

  1. class application.debug.Logging
  2. {
  3.    var enabled;
  4.    var logging;
  5.    static var instance;
  6.    function Logging()
  7.    {
  8.       this.enabled = false;
  9.       this.logging = null;
  10.    }
  11.    static function getInstance()
  12.    {
  13.       if(application.debug.Logging.instance == null)
  14.       {
  15.          application.debug.Logging.instance = new application.debug.Logging();
  16.       }
  17.       return application.debug.Logging.instance;
  18.    }
  19.    function enableLogging()
  20.    {
  21.       this.enabled = true;
  22.       this.logging = new XMLSocket();
  23.       this.logging.connect("localhost",4445);
  24.       this.logging.send("<appName>T-Online_CDV6_0_build_2</appName>\n");
  25.       this.logging.send("<identify/>\n");
  26.    }
  27.    function addKey(keyName, color)
  28.    {
  29.       if(!this.enabled)
  30.       {
  31.          return undefined;
  32.       }
  33.       this.logging.send("<setKey><name>" + keyName + "</name><color>" + color + "</color></setKey>\n");
  34.    }
  35.    function startFoldMessage(keyName, title)
  36.    {
  37.       if(!this.enabled)
  38.       {
  39.          return undefined;
  40.       }
  41.       this[keyName] = new String();
  42.       this[keyName] += "<showFoldMessage key=\'" + keyName + "\'><title>" + title + "</title><message>";
  43.    }
  44.    function addToFoldMessage(keyName, message)
  45.    {
  46.       if(!this.enabled)
  47.       {
  48.          return undefined;
  49.       }
  50.       this[keyName] += message + "\n";
  51.    }
  52.    function endFoldMessage(keyName)
  53.    {
  54.       if(!this.enabled)
  55.       {
  56.          return undefined;
  57.       }
  58.       this[keyName] += "</message></showFoldMessage>\n";
  59.       this.logging.send(this.replaceSpecialChars(this[keyName]));
  60.       delete this[keyName];
  61.    }
  62.    function showMessage(s)
  63.    {
  64.       if(!this.enabled)
  65.       {
  66.          return undefined;
  67.       }
  68.       this.logging.send("<showMessage>" + s + "</showMessage>\n");
  69.    }
  70.    function showKeyedMessage(keyName, s)
  71.    {
  72.       if(!this.enabled)
  73.       {
  74.          return undefined;
  75.       }
  76.       this.logging.send("<showMessage key=\'" + keyName + "\'>" + s + "</showMessage>\n");
  77.    }
  78.    function replaceSpecialChars(s)
  79.    {
  80.       s = this.replaceChars(s,"&nl;","\n");
  81.       s = this.replaceChars(s,"&","und");
  82.       return s;
  83.    }
  84.    function replaceChars(s, char, replaceString)
  85.    {
  86.       var _loc6_ = "searching";
  87.       var _loc9_ = 0;
  88.       while(_loc6_ == "searching")
  89.       {
  90.          var _loc5_ = s.indexOf(char,_loc9_);
  91.          if(_loc5_ == -1)
  92.          {
  93.             _loc6_ = "done";
  94.          }
  95.          else
  96.          {
  97.             var _loc2_ = s.split(char);
  98.             var _loc3_ = new String();
  99.             var _loc1_ = 0;
  100.             while(_loc1_ < _loc2_.length)
  101.             {
  102.                _loc3_ += _loc2_[_loc1_];
  103.                if(_loc1_ != _loc2_.length - 1)
  104.                {
  105.                   _loc3_ += replaceString;
  106.                }
  107.                _loc1_ = _loc1_ + 1;
  108.             }
  109.             s = _loc3_;
  110.          }
  111.       }
  112.       return s;
  113.    }
  114. }
  115.