Skip to main content

Logging & Debugging

The fl-foundation library abstracts away platform-dependent functionality and exposes a platform-agnostic API for the consuming modules.

It primarily focuses on the following features:

  1. Networking using HttpClient
  2. Storage using KeyValueStore
  3. Logging using Logger

Logger

You 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" }

The 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

The PlayerBuilder accepts a logger, and application developers 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

You can configure the logger for download during DownloadManager creation.

val logger = FoundationFactory.defaultPlatformFactory().loggerWith {
tag("FL-DOWNLOADER")
prefixCallSiteInfo(true)
maxVerboseLevel(Logger.Level.INFO)
}
DownloadManager.create(this, logger).resumeDownloads()