/**
 * Created by liutiantian on 2015/1/22.
 */

var locale_svn_version = 302;

function MyLog() {
    if(typeof MyLog.initialized == "undefined") {
        MyLog.prototype.i = function(file, method, msg) {
            var segments = ["iqqi_browser_version"];
            if(!!file) {
                segments.push(file + ".js");
            }
            if(!!method) {
                segments.push(method);
            }
            if(!!msg) {
                segments.push(msg);
            }
            if(!!segments) {
                if(host.tv) {
                    try {
                        if(!!window.Hisense && !!Hisense.log) {
                            Hisense.log("[JS-WARN] " + segments.join(", "));
                        }
                        else if(typeof log != "undefined" && !!log.warn) {
                            log.warn(segments.join(", "));
                        }
                        else {
                            console.warn(segments.join(", "));
                        }
                    }
                    catch(ex) {
                        console.warn(segments.join(", "));
                        console.error("iqqi_browser_version, debug, MyLog.i, show error happened when call log.info: " + ex);
                    }
                    return;
                }
                console.info(segments.join(", "));
            }
        };

        MyLog.prototype.e = function(file, method, msg, error) {
            var segments = ["iqqi_browser_version"];
            if(!!file) {
                segments.push(file + ".js");
            }
            if(!!method) {
                segments.push(method);
            }
            if(!!msg) {
                segments.push(msg);
            }
            if(!!error) {
                segments.push("stack: " + error["stack"]);
            }
            segments.push("svn version: " + locale_svn_version);
            if(!!segments) {
                if(host.tv) {
                    if(host.test) {
                        var log_area = document.getElementById("iqqi_log_area_" + host.browser + "_" + host.screen);
                        if(!!log_area) {
                            log_area.style.display = "block";
                            if(!!log_area.innerHTML) {
                                log_area.innerHTML += "<br />" + segments.join(", ");
                                return;
                            }
                            log_area.innerHTML = segments.join(", ");
                        }
                    }
                    try {
                        if(!!window.Hisense && !!Hisense.log) {
                            Hisense.log("[JS-ERROR] " + segments.join(", "));
                        }
                        else if(typeof log != "undefined" && !!log.error) {
                            log.error(segments.join(", "));
                        }
                        else {
                            console.error(segments.join(", "));
                        }
                    }
                    catch(ex) {
                        console.error(segments.join(", "));
                        console.error("iqqi_browser_version, debug, MyLog.e, show error happened when call log.error: " + ex);
                    }
                    return;
                }
                console.error(segments.join(", "));
            }
        };
    }
    MyLog.initialized = true;
}
