# JavaScriptConsoleCallback.ConsoleMessage

# JavaScriptConsoleCallback.ConsoleMessage

Artifact:[androidx.javascriptengine:javascriptengine](https://developer.android.com/jetpack/androidx/releases/javascriptengine)  
[View Source](https://cs.android.com/search?q=file:androidx/javascriptengine/JavaScriptConsoleCallback.java+class:androidx.javascriptengine.JavaScriptConsoleCallback.ConsoleMessage)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage "View this page in Java")

<br />

```
class JavaScriptConsoleCallback.ConsoleMessage
```

<br />

*** ** * ** ***

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

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LEVEL_DEBUG](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#LEVEL_DEBUG())` = 2` Level for debug-level messages, usually generated through console.debug() or console.count().  |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LEVEL_ERROR](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#LEVEL_ERROR())` = 8` Level for error-level messages, usually generated through console.error() or console.assert(). |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LEVEL_INFO](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#LEVEL_INFO())` = 4` Level for info-level messages, usually generated through console.info() or console.trace().      |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LEVEL_LOG](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#LEVEL_LOG())` = 1` Level for log-level messages, usually generated through console.log().                             |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LEVEL_WARNING](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#LEVEL_WARNING())` = 16` Level for warning-level messages, usually generated through console.warn().               |

|                                                                                                                                                                                                                                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ConsoleMessage](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#ConsoleMessage(int,java.lang.String,java.lang.String,int,int,java.lang.String))`(` ` level: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` message: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` source: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` line: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` column: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` trace: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` `)` Construct a new ConsoleMessage |

|                               ### Public functions                                |
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)       | [getColumn](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#getColumn())`()` Return the column number producing the message                                                           |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)       | [getLevel](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#getLevel())`()` Return the log level.                                                                                      |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)       | [getLine](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#getLine())`()` Return the line number producing the message                                                                 |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getMessage](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#getMessage())`()` Return the message body                                                                                |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [toString](https://developer.android.com/reference/kotlin/androidx/javascriptengine/JavaScriptConsoleCallback.ConsoleMessage#toString())`()` 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](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
const val LEVEL_DEBUG = 2: Int
```

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

### LEVEL_ERROR

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
const val LEVEL_ERROR = 8: Int
```

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

### LEVEL_INFO

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
const val LEVEL_INFO = 4: Int
```

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

### LEVEL_LOG

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
const val LEVEL_LOG = 1: Int
```

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

### LEVEL_WARNING

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
const val LEVEL_WARNING = 16: Int
```

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

## Public constructors

### ConsoleMessage

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
ConsoleMessage(
    level: Int,
    message: String,
    source: String,
    line: Int,
    column: Int,
    trace: String?
)
```

Construct a new ConsoleMessage  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| `level: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | the message (error/verbosity) level                          |
| `message: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)  | the message body                                             |
| `source: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)   | the source file/expression where the message was generated   |
| `line: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | line number of where the message was generated               |
| `column: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | column number of where the message was generated             |
| `trace: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | stack trace of where the message was generated, if available |

## Public functions

### getColumn

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
fun getColumn(): Int
```

Return the column number producing the message  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the column number producing the message |

### getLevel

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
fun getLevel(): Int
```

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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the log level |

### getLine

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
fun getLine(): Int
```

Return the line number producing the message  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the line number producing the message |

### getMessage

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/javascriptengine#1.0.0)  

```
fun getMessage(): String
```

Return the message body  

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the message body |

### toString

```
fun toString(): String
```

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                                      |
|-----------------------------------------------------------------------------------|-------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | a string representation of this console message |