STWLoggerHelper

open class STWLoggerHelper

This class represent the Logger interface between the user main module and the Core module.

  • To delegate the user logs in the Core module you can use LOGGER instance.
  • To enable, disable, export, archive, get prefs or get DB file use execute method

The following example gives an idea how to use this logger :

  1. Delegate the logs in the SW Core :
    
    STWLoggerHelper.LOGGER.d(Pair.create(CLASS_NAME, "methodName"),
        TAG, "this is a DEBUG log message");
    
    STWLoggerHelper.LOGGER.i(Pair.create(CLASS_NAME, "methodName"),
        TAG, "this is an INFO log message");
    
    STWLoggerHelper.LOGGER.w(Pair.create(CLASS_NAME, "methodName"),
        TAG, "this is a WARNING log message");
    
    STWLoggerHelper.LOGGER.e(Pair.create(CLASS_NAME, "methodName"),
        TAG, "this is an ERROR log message");
    
    STWLoggerHelper.LOGGER.e(Pair.create(CLASS_NAME, "methodName"),
        throwable, TAG, "this is an ERROR with exception log message");
    
  2. Execute command log :
    
    STWLoggerHelper.execute(context, Command.LOG_ON, null);
    
    
    STWLoggerHelper.execute(context, Command.LOG_OFF, null);
    
    
    STWLoggerHelper.execute(context, Command.LOG_EXPORT, new STWLoggerHelper.Callback() {
    
        public void onStart() {
    
        }
    
        public void onFinish(Object data) {
            if (data != null) {
                List<Uri> list = (List<Uri>) data;
    
                if (list.isEmpty() == false) {
                    // send report
                }
            }
        }
    });
    
    
    STWLoggerHelper.execute(context, Command.CRASH, new STWLoggerHelper.Callback() {
    
        public void onStart() {
    
        }
    
        public void onFinish(Object data) {
            if (data != null) {
                List<Uri> list = (List<Uri>) data;
    
                if (list.isEmpty() == false) {
                    // send the crash files
                }
            }
        }
    });
    
    
    STWLoggerHelper.execute(context, Command.LOCAL_PREFS, new STWLoggerHelper.Callback() {
    
        public void onStart() {
    
        }
    
        public void onFinish(Object data) {
            if (data != null) {
                List<Uri> list = (List<Uri>) data;
    
                if (list.isEmpty() == false) {
                    // send the prefs files
                }
            }
        }
    });
    
    
    STWLoggerHelper.execute(context, Command.LOCAL_DB, new STWLoggerHelper.Callback() {
    
        public void onStart() {
    
        }
    
        public void onFinish(Object data) {
            if (data != null) {
                List<Uri> list = (List<Uri>) data;
    
                if (list.isEmpty() == false) {
                    // send the DB files
                }
            }
        }
    });
    
    
    STWLoggerHelper.createReport(context, comment, extraFileList, new ReportCallback() {
    
        public void onStarted() {
    
        }
    
        public void onProgress(long transferredBytes, long totalBytes) {
    
        }
    
        public void onCompleted(long totalSize) {
    
        }
    
        public void onError(boolean isInfected) {
    
        }
    
        public void onFail(String reason) { {
    
        }
    });
    }
    </pre>
    <p>
    </li>
    </ol>
    </p>

Types

Link copied to clipboard
interface Callback<Result>
Link copied to clipboard
interface LoggerCallback<Result>
Link copied to clipboard
open class LoggerDelegate

Properties

Link copied to clipboard
val LOGGER: STWLoggerHelper.LoggerDelegate
Logger instance to let another module outside Core logging information

Functions

Link copied to clipboard
open fun createReport(    @NonNull context: Context,     @Nullable comment: String,     @Nullable deviceInfo: String,     @Nullable extraFileList: List<Uri>,     @Nullable callback: ReportCallback)
A public method useful when you want to export the logger zip file with comments and/or files.
Link copied to clipboard
open fun debuggableMode(@NonNull context: Context, debuggableMode: Boolean)
Set to true if this application would like to allow show logs in LogCat of Android Studio
Link copied to clipboard
open fun enableLogs(@NonNull context: Context, enable: Boolean)
Call this method if you want to enable/disable logs
Link copied to clipboard
open fun exportLocalDB(@NonNull context: Context, @Nullable callback: STWLoggerHelper.LoggerCallback<List<Uri>>)
Call this method if you want to export local data base.
Link copied to clipboard
open fun extractCrashStackTraces(@NonNull context: Context, @Nullable callback: STWLoggerHelper.LoggerCallback<List<Uri>>)
Call this method if you want to retrieve crash stack traces file
Link copied to clipboard
open fun extractLocalPrefs(@NonNull context: Context, @Nullable callback: STWLoggerHelper.Callback<List<Uri>>)
Call this method if you want to enable/disable logs
Link copied to clipboard
open fun extractLogs(@NonNull context: Context, @Nullable callback: STWLoggerHelper.LoggerCallback<List<Uri>>)
Call this method if you want to retrieve log files
Link copied to clipboard
open fun fallbackLogger(@Nullable fallbackLogger: STWFallbackLogger)
Link copied to clipboard
open fun initApplicationLogLevel(@NonNull context: Context, @NonNull applicationLogLevel: LogLevel)
Link copied to clipboard
open fun initLogHeaderFile(@NonNull context: Context, @Nullable headerContentFile: String)
Header content text to be appended on top of each new log file
Link copied to clipboard
open fun initSipStackLogLevel(@NonNull context: Context, @NonNull sipLogLevel: LogLevel)
Link copied to clipboard
open fun initVoIPLogLevel(@NonNull context: Context, @NonNull voIPLogLevel: LogLevel)