@@ -93,6 +93,7 @@ class Initialization
9393 isLoggingEnabled : Boolean = false,
9494 ) {
9595 if (isInitialized) {
96+ debugLog(libdigidocInitLogTag, " libdigidocpp is already initialized; only refreshing the log level" )
9697 setLibdigidocppLogLevel(isLoggingEnabled)
9798 throw AlreadyInitializedException (" Libdigidocpp is already initialized" )
9899 }
@@ -111,6 +112,10 @@ class Initialization
111112 throw erre
112113 }
113114
115+ debugLog(
116+ libdigidocInitLogTag,
117+ " TSL cache directory contains: ${getSchemaDir(context).list()?.joinToString() ? : " (empty)" } " ,
118+ )
114119 initLibDigiDocpp(
115120 context,
116121 getSchemaPath(context),
@@ -130,6 +135,7 @@ class Initialization
130135 )
131136 digidoc.initializeLib(UserAgentUtil .getAppInfo(context), path)
132137 UserAgentUtil .setLibdigidocppVersion(digidoc.version())
138+ debugLog(libdigidocInitLogTag, " Initialized libdigidocpp ${digidoc.version()} (TSL cache: $path )" )
133139 isInitialized = true
134140 }
135141
@@ -189,6 +195,16 @@ class Initialization
189195 context : Context ,
190196 configurationProvider : ConfigurationProvider ,
191197 ) {
198+ debugLog(
199+ libdigidocInitLogTag,
200+ " Applying configuration to libdigidocpp — " +
201+ " TSL URL: ${configurationProvider.tslUrl} , TSA URL: ${configurationProvider.tsaUrl} , " +
202+ " SiVa URL: ${configurationProvider.sivaUrl} , " +
203+ " TSL signer certs: ${configurationProvider.tslCerts.size} , " +
204+ " trust bundle certs: ${configurationProvider.certBundle.size} , " +
205+ " config serial: ${configurationProvider.metaInf.serial} " ,
206+ )
207+
192208 overrideTSLUrl(configurationProvider.tslUrl)
193209 overrideTSLCert(configurationProvider.tslCerts)
194210 overrideSivaUrl(configurationProvider.sivaUrl)
@@ -418,9 +434,19 @@ class Initialization
418434 }
419435
420436 private fun loadConfiguration (context : Context ) {
421- configurationRepository.getConfiguration()?.let { overrideConfiguration(context, it) }
437+ val current = configurationRepository.getConfiguration()
438+ debugLog(
439+ libdigidocInitLogTag,
440+ if (current == null ) {
441+ " No cached configuration yet; will apply it once it is loaded"
442+ } else {
443+ " Applying cached configuration"
444+ },
445+ )
446+ current?.let { overrideConfiguration(context, it) }
422447 CoroutineScope (Main ).launch {
423448 configurationRepository.observeConfigurationUpdates { newConfig ->
449+ debugLog(libdigidocInitLogTag, " Configuration updated; reapplying it to libdigidocpp" )
424450 overrideConfiguration(context, newConfig)
425451 }
426452 }
0 commit comments