Add mailable-log as a dependency:
dependencies {
compile 'com.lukekorth:mailable_log:0.1.6'
}
Add the provider inside the application tag in your AndroidManifest
:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
For those using Gradle ${applicationId}
can be left alone, however Maven users should replace
${applicationId}
with the app's package name.
Initialization should be done as soon as possible, preferably in Application#onCreate
.
MailableLog.init(context, BuildConfig.DEBUG);
Use LoggerFactory
to get a logger instance. Logs can be written at several different levels.
Logger logger = LoggerFactory.getLogger(TAG);
logger.error("message");
MailableLog#buildEmailIntent
must not be called on the main thread.
MailableLog.buildEmailIntent(context, "to-address@example.com", "Email Subject", "file-name.log", prependedStringInLog);
To clear the existing log:
MailableLog.clearLog(context);
mailable-log is open source and available under the MIT license. See the LICENSE file for more info.