Logging & Debugging
The fl-foundation
library aims at abstracting away Platform dependent functionality and expose a platform-agnostic API for the consuming modules.
It primarily focuses on following features:
- Networking using
HttpClient
- Storage using
KeyValueStore
- Logging using
Logger
Logger
One can create a Logger using defaultPlatformFactory
val logger = FoundationFactory.defaultPlatformFactory().loggerWith {
tag("FOUNDATION-SAMPLE")
prefixCallSiteInfo(true)
maxVerboseLevel(Logger.Level.TRACE)
}
logger.trace { "Entering a function" }
logger.debug { "response is $response" }
logger.info { "An information message" }
logger.warn { "Mismatch in data" }
logger.error { "An error occurred" }
Following Logger Levels are supported (ordered in terms of verbosity from the most to the least):
TRACE
DEBUG
INFO
WARN
ERROR
Playback Logger
PlayerBuilder accepts logger and the application develpers can configure a logger with their own tag information and logger levels.
val logger = FoundationFactory.defaultPlatformFactory().loggerWith {
tag("FL-PLAYBACK")
prefixCallSiteInfo(true)
maxVerboseLevel(Logger.Level.INFO)
}
val player = PlayerBuilder()
.logger(logger)
//other configurations
.build(getApplication())
Download Logger
Logger for download can be configured during DownlaodManager creation.
val logger = FoundationFactory.defaultPlatformFactory().loggerWith {
tag("FL-DOWNLOADER")
prefixCallSiteInfo(true)
maxVerboseLevel(Logger.Level.INFO)
}
DownloadManager.create(this, logger).resumeDownloads()