jaroslav@972: /** jaroslav@972: * Back 2 Browser Bytecode Translator jaroslav@972: * Copyright (C) 2012 Jaroslav Tulach jaroslav@972: * jaroslav@972: * This program is free software: you can redistribute it and/or modify jaroslav@972: * it under the terms of the GNU General Public License as published by jaroslav@972: * the Free Software Foundation, version 2 of the License. jaroslav@972: * jaroslav@972: * This program is distributed in the hope that it will be useful, jaroslav@972: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@972: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@972: * GNU General Public License for more details. jaroslav@972: * jaroslav@972: * You should have received a copy of the GNU General Public License jaroslav@972: * along with this program. Look for COPYING file in the top folder. jaroslav@972: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@972: */ jaroslav@972: package org.apidesign.bck2brwsr.htmlpage; jaroslav@972: jaroslav@972: import java.util.logging.Logger; jaroslav@972: import javafx.scene.web.WebEngine; jaroslav@972: import netscape.javascript.JSObject; jaroslav@972: jaroslav@972: /** jaroslav@972: * jaroslav@972: * @author Jaroslav Tulach jaroslav@972: */ jaroslav@972: public class Console { jaroslav@972: private static final Logger LOG = Logger.getLogger(Console.class.getName()); jaroslav@972: jaroslav@972: private Console() { jaroslav@972: } jaroslav@972: jaroslav@972: static void register(WebEngine web) { jaroslav@972: ((JSObject)web.executeScript("window")).setMember("jconsole", new Console()); jaroslav@972: web.executeScript("console.log = function(m) { jconsole.log(m); };"); jaroslav@972: web.executeScript("console.info = function(m) { jconsole.log(m); };"); jaroslav@972: web.executeScript("console.error = function(m) { jconsole.log(m); };"); jaroslav@972: web.executeScript("console.warn = function(m) { jconsole.log(m); };"); jaroslav@972: } jaroslav@972: jaroslav@972: public void log(String msg) { jaroslav@972: LOG.info(msg); jaroslav@972: } jaroslav@972: }