JavaScriptConsoleCallback.ConsoleMessage


public final class JavaScriptConsoleCallback.ConsoleMessage


Representation of a console message, such as produced by console.log.

Summary

Constants

static final int

Level for debug-level messages, usually generated through console.debug() or console.count().

static final int

Level for error-level messages, usually generated through console.error() or console.assert().

static final int

Level for info-level messages, usually generated through console.info() or console.trace().

static final int

Level for log-level messages, usually generated through console.log().

static final int

Level for warning-level messages, usually generated through console.warn().

Public constructors

ConsoleMessage(
    int level,
    @NonNull String message,
    @NonNull String source,
    int line,
    int column,
    @Nullable String trace
)

Construct a new ConsoleMessage

Public methods

int

Return the column number producing the message

int

Return the log level.

int

Return the line number producing the message

@NonNull String

Return the message body

@NonNull String

Return a string representation of this console message, including the message body and where it came from.

Constants

LEVEL_DEBUG

Added in 1.0.0-beta01
public static final int LEVEL_DEBUG = 2

Level for debug-level messages, usually generated through console.debug() or console.count().

LEVEL_ERROR

Added in 1.0.0-beta01
public static final int LEVEL_ERROR = 8

Level for error-level messages, usually generated through console.error() or console.assert().

LEVEL_INFO

Added in 1.0.0-beta01
public static final int LEVEL_INFO = 4

Level for info-level messages, usually generated through console.info() or console.trace().

LEVEL_LOG

Added in 1.0.0-beta01
public static final int LEVEL_LOG = 1

Level for log-level messages, usually generated through console.log().

LEVEL_WARNING

Added in 1.0.0-beta01
public static final int LEVEL_WARNING = 16

Level for warning-level messages, usually generated through console.warn().

Public constructors

ConsoleMessage

Added in 1.0.0-beta01
public ConsoleMessage(
    int level,
    @NonNull String message,
    @NonNull String source,
    int line,
    int column,
    @Nullable String trace
)

Construct a new ConsoleMessage

Parameters
int level

the message (error/verbosity) level

@NonNull String message

the message body

@NonNull String source

the source file/expression where the message was generated

int line

line number of where the message was generated

int column

column number of where the message was generated

@Nullable String trace

stack trace of where the message was generated, if available

Public methods

getColumn

Added in 1.0.0-beta01
public int getColumn()

Return the column number producing the message

Returns
int

the column number producing the message

getLevel

Added in 1.0.0-beta01
public int getLevel()

Return the log level.

ConsoleMessages can be filtered by level using a bitmask of the desired levels. However, any ConsoleMessage will only have one level associated with it.

Returns
int

the log level

getLine

Added in 1.0.0-beta01
public int getLine()

Return the line number producing the message

Returns
int

the line number producing the message

getMessage

Added in 1.0.0-beta01
public @NonNull String getMessage()

Return the message body

Returns
@NonNull String

the message body

toString

public @NonNull String toString()

Return a string representation of this console message, including the message body and where it came from.

Do not try to parse the result of this method as its format may change across JavaScriptEngine versions.

Returns
@NonNull String

a string representation of this console message