client/annotviz/app/js/logger.js
author rougeronj
Wed, 21 Jan 2015 20:43:05 +0100
changeset 104 685c5ebc59d0
parent 98 72d767c5142d
child 131 0bb70072a56f
permissions -rw-r--r--
update resolution screen

/**
* js/wswrapper.js
*
* simple logger service
*
*/

/* global document: false */

'use strict';

function HtmlLogger(doLog, container) {

    var logContainer = container;
    if(typeof(container) === 'string') {
        logContainer = document.getElementById(container);
    }
    if(!doLog) {
        document.body.removeChild(logContainer);
        logContainer = undefined;
    }


    this.log = function(msg) {
        if(doLog && logContainer) {
            logContainer.innerHTML += msg + '\n';
            logContainer.scrollTop = logContainer.scrollHeight;
        }
    };
}

function ConsoleLogger(doLog) {

    this.log = function(msg) {
        if(doLog) {
            console.log(msg);
        }
    }

}

module.exports = {
    HtmlLogger: HtmlLogger,
    ConsoleLogger: ConsoleLogger
};