Search in sources :

Example 1 with WebConsole

use of com.gargoylesoftware.htmlunit.WebConsole in project htmlunit by HtmlUnit.

the class Console method info.

/**
 * This method performs logging to the console at {@code info} level.
 * @param cx the JavaScript context
 * @param thisObj the scriptable
 * @param args the arguments passed into the method
 * @param funObj the function
 */
@JsxFunction
public static void info(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) {
    final WebConsole webConsole = toWebConsole(thisObj);
    final Formatter oldFormatter = webConsole.getFormatter();
    webConsole.setFormatter(FORMATTER_);
    webConsole.info(args);
    webConsole.setFormatter(oldFormatter);
}
Also used : WebConsole(com.gargoylesoftware.htmlunit.WebConsole) Formatter(com.gargoylesoftware.htmlunit.WebConsole.Formatter) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Example 2 with WebConsole

use of com.gargoylesoftware.htmlunit.WebConsole in project htmlunit by HtmlUnit.

the class Console method log.

/**
 * This method performs logging to the console at {@code log} level.
 * @param cx the JavaScript context
 * @param thisObj the scriptable
 * @param args the arguments passed into the method
 * @param funObj the function
 */
@JsxFunction
public static void log(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) {
    final WebConsole webConsole = toWebConsole(thisObj);
    final Formatter oldFormatter = webConsole.getFormatter();
    webConsole.setFormatter(FORMATTER_);
    webConsole.info(args);
    webConsole.setFormatter(oldFormatter);
}
Also used : WebConsole(com.gargoylesoftware.htmlunit.WebConsole) Formatter(com.gargoylesoftware.htmlunit.WebConsole.Formatter) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Example 3 with WebConsole

use of com.gargoylesoftware.htmlunit.WebConsole in project htmlunit by HtmlUnit.

the class Console method trace.

/**
 * This method performs logging to the console at {@code trace} level.
 * @param cx the JavaScript context
 * @param thisObj the scriptable
 * @param args the arguments passed into the method
 * @param funObj the function
 */
@JsxFunction
public static void trace(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) {
    final RhinoException e = ScriptRuntime.throwError(cx, funObj, null);
    final WebConsole webConsole = toWebConsole(thisObj);
    final Formatter oldFormatter = webConsole.getFormatter();
    webConsole.setFormatter(FORMATTER_);
    webConsole.info(e.getScriptStackTrace());
    webConsole.setFormatter(oldFormatter);
}
Also used : WebConsole(com.gargoylesoftware.htmlunit.WebConsole) Formatter(com.gargoylesoftware.htmlunit.WebConsole.Formatter) RhinoException(net.sourceforge.htmlunit.corejs.javascript.RhinoException) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Example 4 with WebConsole

use of com.gargoylesoftware.htmlunit.WebConsole in project htmlunit by HtmlUnit.

the class Console method warn.

/**
 * This method performs logging to the console at {@code warn} level.
 * @param cx the JavaScript context
 * @param thisObj the scriptable
 * @param args the arguments passed into the method
 * @param funObj the function
 */
@JsxFunction
public static void warn(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) {
    final WebConsole webConsole = toWebConsole(thisObj);
    final Formatter oldFormatter = webConsole.getFormatter();
    webConsole.setFormatter(FORMATTER_);
    webConsole.warn(args);
    webConsole.setFormatter(oldFormatter);
}
Also used : WebConsole(com.gargoylesoftware.htmlunit.WebConsole) Formatter(com.gargoylesoftware.htmlunit.WebConsole.Formatter) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Example 5 with WebConsole

use of com.gargoylesoftware.htmlunit.WebConsole in project htmlunit by HtmlUnit.

the class Console method debug.

/**
 * This method performs logging to the console at {@code debug} level.
 * @param cx the JavaScript context
 * @param thisObj the scriptable
 * @param args the arguments passed into the method
 * @param funObj the function
 */
@JsxFunction
public static void debug(final Context cx, final Scriptable thisObj, final Object[] args, final Function funObj) {
    final WebConsole webConsole = toWebConsole(thisObj);
    final Formatter oldFormatter = webConsole.getFormatter();
    webConsole.setFormatter(FORMATTER_);
    webConsole.debug(args);
    webConsole.setFormatter(oldFormatter);
}
Also used : WebConsole(com.gargoylesoftware.htmlunit.WebConsole) Formatter(com.gargoylesoftware.htmlunit.WebConsole.Formatter) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Aggregations

WebConsole (com.gargoylesoftware.htmlunit.WebConsole)10 Formatter (com.gargoylesoftware.htmlunit.WebConsole.Formatter)6 JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)6 WebClient (com.gargoylesoftware.htmlunit.WebClient)2 Logger (com.gargoylesoftware.htmlunit.WebConsole.Logger)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)1 RhinoException (net.sourceforge.htmlunit.corejs.javascript.RhinoException)1 Test (org.junit.Test)1