Search in sources :

Example 1 with Formatter

use of com.gargoylesoftware.htmlunit.WebConsole.Formatter 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 Formatter

use of com.gargoylesoftware.htmlunit.WebConsole.Formatter 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 Formatter

use of com.gargoylesoftware.htmlunit.WebConsole.Formatter 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 Formatter

use of com.gargoylesoftware.htmlunit.WebConsole.Formatter 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 Formatter

use of com.gargoylesoftware.htmlunit.WebConsole.Formatter 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)6 Formatter (com.gargoylesoftware.htmlunit.WebConsole.Formatter)6 JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)6 RhinoException (net.sourceforge.htmlunit.corejs.javascript.RhinoException)1