McuMgrLogger

class McuMgrLogger @JvmOverloads constructor(val category: Category, source: String? = null)

A log emitter used internally by the Mcu Manager library.

Each layer of the library owns an instance of this class, bound to the Category that layer reports under. The sink is assigned by the application, and passed down from one layer to the next; it may be changed at any time, or set to null to stop logging. Log messages are built only when a sink is set.

The formatting methods accept the {} placeholder syntax and, like most logging facades, treat a trailing Throwable that has no matching placeholder as the throwable associated with the entry:

LOG.info("Uploading {} bytes", length);
LOG.error("Upload failed", exception);

From Kotlin, prefer the lambda overloads, which avoid building the message when no sink is set:

LOG.info { "Uploading $length bytes" }

Constructors

Link copied to clipboard
constructor(category: Category, source: String? = null)

Properties

Link copied to clipboard

The category all entries from this logger are reported under.

Link copied to clipboard
var sink: Log.Sink<Category>?

The sink receiving the log entries, assigned by the application.

Functions

Link copied to clipboard
fun debug(format: String, vararg args: Any?)

Logs a message at the DEBUG level.

fun debug(throwable: Throwable? = null, message: () -> String)

Logs a lazily built message at the DEBUG level.

Link copied to clipboard
fun error(format: String, vararg args: Any?)

Logs a message at the ERROR level.

fun error(throwable: Throwable? = null, message: () -> String)

Logs a lazily built message at the ERROR level.

Link copied to clipboard
fun info(format: String, vararg args: Any?)

Logs a message at the INFO level.

fun info(throwable: Throwable? = null, message: () -> String)

Logs a lazily built message at the INFO level.

Link copied to clipboard
fun trace(format: String, vararg args: Any?)

Logs a message at the TRACE level.

fun trace(throwable: Throwable? = null, message: () -> String)

Logs a lazily built message at the TRACE level.

Link copied to clipboard
fun warn(format: String, vararg args: Any?)

Logs a message at the WARN level.

fun warn(throwable: Throwable? = null, message: () -> String)

Logs a lazily built message at the WARN level.