use of com.microsoft.azure.mobile.ingestion.models.json.CustomPropertiesLogFactory in project mobile-center-sdk-android by Microsoft.
the class MobileCenter method instanceConfigure.
/**
* Internal SDK configuration.
*
* @param application application context.
* @param appSecret a unique and secret key used to identify the application.
* @return true if configuration was successful, false otherwise.
*/
/* UncaughtExceptionHandler is used by PowerMock but lint does not detect it. */
@SuppressLint("VisibleForTests")
private synchronized boolean instanceConfigure(Application application, String appSecret) {
/* Load some global constants. */
Constants.loadFromContext(application);
/* Enable a default log level for debuggable applications. */
if (!mLogLevelConfigured && Constants.APPLICATION_DEBUGGABLE) {
MobileCenterLog.setLogLevel(Log.WARN);
}
/* Parse and store parameters. */
if (mApplication != null) {
MobileCenterLog.warn(LOG_TAG, "Mobile Center may only be configured once");
return false;
} else if (application == null) {
MobileCenterLog.error(LOG_TAG, "application may not be null");
} else if (appSecret == null || appSecret.isEmpty()) {
MobileCenterLog.error(LOG_TAG, "appSecret may not be null or empty");
} else {
/* Store state. */
mApplication = application;
mAppSecret = appSecret;
/* If parameters are valid, init context related resources. */
StorageHelper.initialize(application);
/* Remember state to avoid double call PreferencesStorage. */
boolean enabled = isInstanceEnabled();
/* Init uncaught exception handler. */
mUncaughtExceptionHandler = new UncaughtExceptionHandler();
if (enabled)
mUncaughtExceptionHandler.register();
mServices = new HashSet<>();
/* Init channel. */
mLogSerializer = new DefaultLogSerializer();
mLogSerializer.addLogFactory(StartServiceLog.TYPE, new StartServiceLogFactory());
mLogSerializer.addLogFactory(CustomPropertiesLog.TYPE, new CustomPropertiesLogFactory());
mChannel = new DefaultChannel(application, appSecret, mLogSerializer);
mChannel.setEnabled(enabled);
mChannel.addGroup(CORE_GROUP, DEFAULT_TRIGGER_COUNT, DEFAULT_TRIGGER_INTERVAL, DEFAULT_TRIGGER_MAX_PARALLEL_REQUESTS, null);
if (mLogUrl != null)
mChannel.setLogUrl(mLogUrl);
MobileCenterLog.logAssert(LOG_TAG, "Mobile Center SDK configured successfully.");
return true;
}
MobileCenterLog.logAssert(LOG_TAG, "Mobile Center SDK configuration failed.");
return false;
}
Aggregations