Class LoggingService
-
- All Implemented Interfaces:
public final class LoggingService extends MobileService
Represents the service to handle log related task.
-
-
Field Summary
Fields Modifier and Type Field Description private BooleanautoUploadprivate LogUploadTypeautoUploadTypeprivate LogPolicypolicyprivate BooleanlogToConsoleprivate Applicationapplicationprivate StringapiKey
-
Constructor Summary
Constructors Constructor Description LoggingService(Boolean autoUpload, LogUploadType autoUploadType)LoggingService(Boolean autoUpload)LoggingService()
-
Method Summary
Modifier and Type Method Description final BooleangetAutoUpload()Whether logs are uploaded automatically. final UnitsetAutoUpload(Boolean value)Whether logs are uploaded automatically. final LogUploadTypegetAutoUploadType()The LogUploadType used for automatic uploads when autoUpload is true.final UnitsetAutoUploadType(LogUploadType value)The LogUploadType used for automatic uploads when autoUpload is true.final LogPolicygetPolicy()The log policy final UnitsetPolicy(LogPolicy <set-?>)The log policy final BooleangetLogToConsole()Whether log information to the logcat console final UnitsetLogToConsole(Boolean <set-?>)Whether log information to the logcat console Unitinit(Application application, String apiKey)Initializes the mobile service UnitonStateChange(ApplicationState state)Notified when application state changes. Unitreset()Resets the mobile service to the state that just initialized. final Jobexport(ServiceListener<File> listener)Exports the log in the returned file. final InputStreamexport()Exports the log in the returned input stream. final Jobupload(LifecycleOwner owner, LogUploadType uploadType, ServiceListener<Boolean> listener, Function1<Integer, Unit> progressReporter)Uploads the log. final Jobupload(LifecycleOwner owner, LogUploadType uploadType, ServiceListener<Boolean> listener)Uploads the log. final Jobupload(LifecycleOwner owner, LogUploadType uploadType)Uploads the log. final Jobupload(LifecycleOwner owner)Uploads the log. final Jobupload()Uploads the log. -
Methods inherited from class com.sap.cloud.mobile.foundation.mobileservices.MobileService
enableNetworkPolicy, getApiKey, getApplication, isApplicationInitialized, mayStartNewProcess, setApiKey, setApplication -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
LoggingService
LoggingService(Boolean autoUpload, LogUploadType autoUploadType)
-
LoggingService
LoggingService(Boolean autoUpload)
-
LoggingService
LoggingService()
-
-
Method Detail
-
getAutoUpload
final Boolean getAutoUpload()
Whether logs are uploaded automatically. When
true, logs are uploaded in the background without any explicit call to upload. Automatic uploads are triggered when a client policy is retrieved (see onStateChange) and whenever a log file rolls over because it reached its size limit. Automatic uploads only run when log upload is enabled by the active policy; otherwise they are skipped. Defaults tofalse, meaning logs are uploaded only when upload is called explicitly. Changing this value after the service is initialized re-configures the logging service.
-
setAutoUpload
final Unit setAutoUpload(Boolean value)
Whether logs are uploaded automatically. When
true, logs are uploaded in the background without any explicit call to upload. Automatic uploads are triggered when a client policy is retrieved (see onStateChange) and whenever a log file rolls over because it reached its size limit. Automatic uploads only run when log upload is enabled by the active policy; otherwise they are skipped. Defaults tofalse, meaning logs are uploaded only when upload is called explicitly. Changing this value after the service is initialized re-configures the logging service.
-
getAutoUploadType
final LogUploadType getAutoUploadType()
The LogUploadType used for automatic uploads when autoUpload is
true. Defaults to LogUploadType.DEFAULT.
-
setAutoUploadType
final Unit setAutoUploadType(LogUploadType value)
The LogUploadType used for automatic uploads when autoUpload is
true. Defaults to LogUploadType.DEFAULT.
-
getLogToConsole
final Boolean getLogToConsole()
Whether log information to the logcat console
-
setLogToConsole
final Unit setLogToConsole(Boolean <set-?>)
Whether log information to the logcat console
-
init
Unit init(Application application, String apiKey)
Initializes the mobile service
-
onStateChange
Unit onStateChange(ApplicationState state)
Notified when application state changes. This function will be called on Main thread.
-
reset
@WorkerThread() Unit reset()
Resets the mobile service to the state that just initialized.
-
export
@Deprecated(message = "Deprecated since 25.4.0", replaceWith = @ReplaceWith(expression = "export()")) final Job export(ServiceListener<File> listener)
Exports the log in the returned file.
-
export
final InputStream export()
Exports the log in the returned input stream.
-
upload
@JvmOverloads() final Job upload(LifecycleOwner owner, LogUploadType uploadType, ServiceListener<Boolean> listener, Function1<Integer, Unit> progressReporter)
Uploads the log.
- Parameters:
owner- The optional lifecycle owner, either an activity or a fragment.uploadType- The optional upload type, please see LogUploadType.listener- The optional upload status listener, it will be notified on the main thread.progressReporter- The optional file upload progress reporter.
-
upload
@JvmOverloads() final Job upload(LifecycleOwner owner, LogUploadType uploadType, ServiceListener<Boolean> listener)
Uploads the log.
- Parameters:
owner- The optional lifecycle owner, either an activity or a fragment.uploadType- The optional upload type, please see LogUploadType.listener- The optional upload status listener, it will be notified on the main thread.
-
upload
@JvmOverloads() final Job upload(LifecycleOwner owner, LogUploadType uploadType)
Uploads the log.
- Parameters:
owner- The optional lifecycle owner, either an activity or a fragment.uploadType- The optional upload type, please see LogUploadType.
-
upload
@JvmOverloads() final Job upload(LifecycleOwner owner)
Uploads the log.
- Parameters:
owner- The optional lifecycle owner, either an activity or a fragment.
-
upload
@JvmOverloads() final Job upload()
Uploads the log.
-
-
-
-