Skip to content
Muhammad Umair Adil edited this page Dec 17, 2018 · 3 revisions

Welcome to the RxLogs wiki!

RxLogs is written in Kotlin and supports RxJava2. It basically features two types of loggers (PLog & DataLog) with many of advanced features needed for logging. Logs are saved in storage directory of Android device. Logs can be compressed and exported as zip file or they can be read as plain String. All configuration is done on logs configuration file. RxLogs must be initialized on application class of project.

PLog

These are hourly log files. They will be created every time a data is sent to be logged to logger. Purpose of keeping separate log files is to easily find data during debugging. These logs are always initialized and accessed by 'PLog' object.

    PLog.logThis(TAG, "buttonOnClick", "Log: " + Math.random(), LogLevel.INFO)

DataLogs

These are custom log files with a distinct name. There are some types provided in this library, but other types can be added too. These types are defined in configuration like this:

     val logsConfig = LogsConfig(logTypesEnabled = arrayListOf("MyLogs"))  

These logs are always initialized and accessed by calling following method:

    val myLog = PLog.getLoggerFor("MyLogs") 
    myLog?.appendToFile("String data to Log..")

Logs Configuration

Name Default Description
isDebuggable true To see output in LogCat
enabled true If this flag is false, no logging will be done
logLevelsEnabled arrayListOf() Levels like Info, Warning, Error, Severe must be added here to enable
logTypesEnabled arrayListOf() Types of logs must be added here, required only for DataLogs
formatType FormatType.FORMAT_CURLY Default format of '{String}' log data
attachTimeStamp false If true, timestamp will be appended to zip file name on export
attachNoOfFiles false If true, count of files in zip will be appended to zip file name on export
timeStampFormat TimeStampFormat.DATE_FORMAT_1 TimeStamp format in PLogs log files
logFileExtension LogExtension.TXT extension of log files
customFormatOpen "" Custom formatting opening character
customFormatClose "" Custom formatting closing character
logsRetentionPeriodInDays 0 Logs will be kept for this number of days
zipsRetentionPeriodInDays 0 Zip will be kept for this number of days
autoDeleteZipOnExport false If set true, then previous exported zip files will be cleared on each export
autoClearLogs false If set true, then auto clear logs functionality will be enabled in app
zipFileName "Output" Name of zip file that will be exported
exportFileNamePreFix "" Name that will be appended to name of zip file that will be exported
exportFileNamePostFix "" Name that will be prepended to name of zip file that will be exported
csvDeliminator "" Delimiter required only for FormatType.CSV
zipFilesOnly true If true, zip will contain files only, otherwise directories & subdirectories will be zipped too
autoExportErrors true On error, error log will be exported as plain string to log event listener
encryptionEnabled false If true, encrypted text will be written to log files
encryptionKey "" Must be provided for encryption
singleLogFileSize 4096 Max size for single log file
logFilesLimit 100 Max number of files that can be created for logging
directoryStructure DirectoryStructure.FOR_DATE Directory structure that logger needs to follow
nameForEventDirectory "" Required only for DirectoryStructure.FOR_EVENT, it can be updated later on each event
logSystemCrashes false Set true, if system crashes needs to be logged. Implementation must be added.
autoExportLogTypes arrayListOf() These log types will automatically be exported on an event.
autoExportLogTypesPeriod 0 No of days to auto export provided log types.
savePath ../"PLogs" Directory to save logs
exportPath ../"PLogs" Directory to export zipped logs