Java Code Examples for jdk.nashorn.internal.runtime.logging.DebugLogger#log()

The following examples show how to use jdk.nashorn.internal.runtime.logging.DebugLogger#log() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodHandleFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
Example 2
Source File: MethodHandleFactory.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 3
Source File: MethodHandleFactory.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 4
Source File: MethodHandleFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 5
Source File: MethodHandleFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
Example 6
Source File: MethodHandleFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 7
Source File: MethodHandleFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 8
Source File: MethodHandleFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
Example 9
Source File: MethodHandleFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 10
Source File: MethodHandleFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 11
Source File: MethodHandleFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 12
Source File: MethodHandleFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 13
Source File: MethodHandleFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 14
Source File: MethodHandleFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
Example 15
Source File: MethodHandleFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 16
Source File: MethodHandleFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 17
Source File: MethodHandleFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
            append(stripName(argString(args[i]))).
            append('\'').
            append(' ').
            append('[').
            append("type=").
            append(args[i] == null ? "null" : stripName(args[i].getClass())).
            append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
Example 18
Source File: MethodHandleFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                ";" :
                " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
Example 19
Source File: MethodHandleFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
Example 20
Source File: MethodHandleFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}