BleLog

object BleLog

Global logging configuration for BLE-X library.

This object provides centralized logging functionality for the entire BLE-X library. It allows configuration of the logging implementation, minimum log level, and provides convenient shorthand methods for logging at different levels.

Configuration

Setting a Custom Logger

// Use a custom logger implementation
BleLog.logger = MyCustomLogger()

Setting the Minimum Log Level

// Only show warnings and errors
BleLog.setLevel(LogLevel.WARN)

// Show all logs
BleLog.setLevel(LogLevel.VERBOSE)

Disabling Logging

// Completely disable all logging
BleLog.disable()

Thread Safety

The logger and minLevel properties are marked as @Volatile to ensure visibility across threads. However, if you need to atomically check and set these properties, external synchronization is required.

Logging Methods

Shorthand logging methods are provided for convenience:

  • v - Verbose

  • d - Debug

  • i - Info

  • w - Warning

  • e - Error

See also

Properties

Link copied to clipboard

The current logger implementation.

Link copied to clipboard

The current minimum log level.

Functions

Link copied to clipboard
fun d(tag: String, message: String)

Logs a debug message.

Link copied to clipboard
fun disable()

Disables all logging by setting the logger to NoOpBleLogger.

Link copied to clipboard
fun e(tag: String, message: String, t: Throwable? = null)

Logs an error message with an optional throwable.

Link copied to clipboard
fun i(tag: String, message: String)

Logs an info message.

Link copied to clipboard
fun setLevel(level: LogLevel)

Sets the minimum log level and updates the logger accordingly.

Link copied to clipboard
fun v(tag: String, message: String)

Logs a verbose message.

Link copied to clipboard
fun w(tag: String, message: String)

Logs a warning message.