Package-level declarations
Logger with export function.
Logger
For logging, libraries use a logger described by the Logger interface. It is recommended to use the same in the application.
val coreContext: CoreContext
val logger: Logger = coreContext.logger
logger.logV(
tag = "TAG",
message = "Hello world",
isImportant = false // Flag for marking a log as important. Can be found in LogEntry
)
// Log levels
logger.logD("TAG", "Hello world")
logger.logV("TAG", "Hello world")
logger.logI("TAG", "Hello world")
logger.logW("TAG", "Hello world")
logger.logE("TAG", "Hello world")
logger.logF("TAG", "Hello world")Content copied to clipboard
Log Interceptor
To process logs, it is possible to create an interceptor.
val coreContext: CoreContext
val logInterceptor: LogInterceptor = object : LogInterceptor {
override suspend fun intercept(entry: LogEntry) {
// Handle it...
}
}
val coreContext: CoreContext = CoreManager.build(
context = applicationContext,
logInterceptors = listOf(logInterceptor)
)Content copied to clipboard
Tags
You can create a logger instance with a tag chain to add customized context to the log.
val logger: Logger
// Method 1
val logger1: Logger = logger.createChild("Hello")
val logger2: Logger = logger1.createChild("World")
logger.logI("!", "Hi") // [I] ! : [Hello] [world] Hi
// Method 2
val logger3: Logger = logger.createChild("Hello", "World")
logger3.logI("!", "Hi") // [I] ! : [Hello] [world] HiContent copied to clipboard
Export
The logger has a file buffer and writes it to the database when it's full. You can export the log from the database to a file.
val logger: Logger
// It doesn't matter from which logger instance you make the call.
// File name example: cloud[v.8.8.0.8][29.05.2026][06-08-07].log
// package_name[package_version_name][date][time].log
val report: File = logger.exportLog(
directory = File(), // Target dir
bytesLimit = 300_000, // Log file limit. Старые записи, выходящие за лимит будут обрезаться
minLogLevel = LogLevel.INFO // Min log level in report
)
// You can clear the log stored in the database with the following call
logger.clearCache()Content copied to clipboard