Skip to main content

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:

  1. Networking using HttpClient
  2. Storage using KeyValueStore
  3. 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):

  1. TRACE
  2. DEBUG
  3. INFO
  4. WARN
  5. 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()