/**
 * A generic logging module
 */

var logging = {
  info: function(txt) {
    this._write(txt);
  },
  
  warn: function(txt) {
    this._write(txt, '#ff0');
  },
  
  error: function(txt) {
    this._write(txt, '#f00', '#fff');
  },
  
  _write: function(txt, bgcolor, color) {
    if (!bgcolor)
      bgcolor = '#fff';
    if (!color)
      color = '#000';
    
    var elt = document.getElementById('_logging');
    if (!elt) {
      elt = document.createElement('div');
      elt.id = '_logging';
      elt.style.height = '300px';
      elt.style.width = '600px';
      elt.style.overflow = 'scroll';
      elt.style.fontSize = '70%';
      document.body.appendChild(elt);
    }
    var d = new Date();
    elt.innerHTML = "<span style='background-color:" + bgcolor
                    + "; color:" + color
                    + ";'>" + d + d.getMilliseconds() + " "
                    + txt + "</span><br />"
                    + elt.innerHTML;
  }
}
