Logging events¶
By default the SDK logs events to the console, however, it is also possible to log these events using firebase or a custom logger implementation.
Logger Factory¶
The start method for the SDK also accepts a class which extends the com.dasnano.logger.LoggerFactory
interface. This
logger factory interface provides the create()
method which must return an instance of a class which implements the
com.dasnano.logger.Logger
interface. Implementations from the LoggerFactory
class cannot have more than one empty
constructor.
Firebase¶
Veridas provides a Firebase logger which is in its own module. This module can be imported
(New... > Module > Import .JAR/.AAR Package) into the app and the dependencies
implementation project (":VDLoggerFirebase")
and implementation('com.google.firebase:firebase-storage:20.0.0')
must
be added to the dependencies section from apps the build.gradle
file.
The next step would be to create the factory class for the Firebase logger, an example (java):
public class FirebaseLoggerFactory implements LoggerFactory {
@Override
public Logger create() {
return FirebaseLogger.Builder()
.appId(/* The firebase app id */)
.folder(/* The firebase folder */)
.projectId(/* The firebase project id */)
.storageBucket(/* The firebase storage bucket name */)
.userId(/* The firebase user id */)
.verificationId(/* The firebase verification id */)
/* or, alternatively, it is possible to provide both the user and verification id as a combined string
* separated by an underscore (_) character.
*/
.userAndVerificationId(/* <user id>_<verification id> */)
.build();
}
}
The same example in Kotlin:
class FirebaseLoggerFactory : LoggerFactory {
override fun create(): Logger {
return FirebaseLogger.Builder()
.appId(/* The firebase app id */)
.folder(/* The firebase folder */)
.projectId(/* The firebase project id */)
.storageBucket(/* The firebase storage bucket name */)
.userId(/* The firebase user id */)
.verificationId(/* The firebase verification id */)
/* or, alternatively, it is possible to provide both the user and verification id as a combined string
* separated by an underscore (_) character.
*/
.userAndVerificationId(/* <user id>_<verification id> */)
.build()
}
}
Then when the SDK is started the class name of the logger factory can be passed to the SDK using the configuration
option VDDocumentCaptureConfiguration.LOGGER_FACTORY_CLASS
, e.g:
Map<String, String> configuration = new HashMap();
configuration.put(VDDocumentCaptureConfiguration.LOGGER_FACTORY_CLASS, FirebaseLoggerFactory.class.name);