[ Index ]
 

Code source de Kupu-1.3.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/common/ -> kupuloggers.js (source)

   1  /*****************************************************************************
   2   *
   3   * Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
   4   *
   5   * This software is distributed under the terms of the Kupu
   6   * License. See LICENSE.txt for license text. For a list of Kupu
   7   * Contributors see CREDITS.txt.
   8   *
   9   *****************************************************************************/
  10  
  11  // $Id: kupuloggers.js 9879 2005-03-18 12:04:00Z yuppie $
  12  
  13  
  14  //----------------------------------------------------------------------------
  15  // Loggers
  16  //
  17  //  Loggers are pretty simple classes, that should have 1 method, called 
  18  //  'log'. This is called with 2 arguments, the first one is the message to
  19  //  log and the second is the severity, which can be 0 or some other false
  20  //  value for debug messages, 1 for warnings and 2 for errors (the loggers
  21  //  are allowed to raise an exception if that happens).
  22  //
  23  //----------------------------------------------------------------------------
  24  
  25  function DebugLogger() {
  26      /* Alert all messages */
  27      
  28      this.log = function(message, severity) {
  29          /* log a message */
  30          if (severity > 1) {
  31              alert("Error: " + message);
  32          } else if (severity == 1) {
  33              alert("Warning: " + message);
  34          } else {
  35              alert("Log message: " + message);
  36          }
  37      };
  38  }
  39  
  40  function PlainLogger(debugelid, maxlength) {
  41      /* writes messages to a debug tool and throws errors */
  42  
  43      this.debugel = getFromSelector(debugelid);
  44      this.maxlength = maxlength;
  45      
  46      this.log = function(message, severity) {
  47          /* log a message */
  48          if (severity > 1) {
  49              throw message;
  50          } else {
  51              if (this.maxlength) {
  52                  if (this.debugel.childNodes.length > this.maxlength - 1) {
  53                      this.debugel.removeChild(this.debugel.childNodes[0]);
  54                  }
  55              }
  56              var now = new Date();
  57              var time = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
  58              
  59              var div = document.createElement('div');
  60              var text = document.createTextNode(time + ' - ' + message);
  61              div.appendChild(text);
  62              this.debugel.appendChild(div);
  63          }
  64      };
  65  }
  66  
  67  function DummyLogger() {
  68      this.log = function(message, severity) {
  69          if (severity > 1) {
  70              throw message;
  71          }
  72      };
  73  };


Généré le : Sun Feb 25 15:30:41 2007 par Balluche grâce à PHPXref 0.7