@Singleton public class LogPersistor extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
BUFFER_SIZE |
protected List<File> |
files |
protected Handler |
handler |
protected static String |
MESSAGE_SEPARATOR |
protected int |
numberOfFiles |
protected boolean |
running |
protected int |
totalDiskQuota |
protected PrintWriter |
writer |
Constructor and Description |
---|
LogPersistor() |
Modifier and Type | Method and Description |
---|---|
void |
archiveLogs(Date dateFrom,
Date dateTo,
File outputFile,
String additionalMessageSeparator,
FileLogger.ArchiveLogsCallback callback) |
void |
clearFiles()
Removes all files that store logs
|
void |
initializeFiles()
Retrieve the log files without opening a writer
|
int |
log(int logLevel,
com.pega.commontools.androidlogger.Message message)
Save the log message to file in a separate thread
|
void |
readLogTail(int recordCountGoal,
FileLogger.ReadLogTailCallback callback)
Read the given number of last records
|
void |
setTotalDiskQuota(int totalDiskQuota)
Specify how much log data should be stored
|
void |
toggle(boolean state)
Start or stop the thread with looper, which is responsible
for storing logs in files
|
protected static final String MESSAGE_SEPARATOR
protected static final int BUFFER_SIZE
protected Handler handler
protected boolean running
protected int totalDiskQuota
protected PrintWriter writer
protected int numberOfFiles
public int log(int logLevel, com.pega.commontools.androidlogger.Message message)
public void initializeFiles()
public void toggle(boolean state)
state
- true to start or false to stoppublic void setTotalDiskQuota(int totalDiskQuota)
totalDiskQuota
- size of log data to store in bytespublic void readLogTail(int recordCountGoal, FileLogger.ReadLogTailCallback callback)
recordCountGoal
- the desired number of recordscallback
- the callback in which to return the resultpublic void archiveLogs(Date dateFrom, Date dateTo, File outputFile, String additionalMessageSeparator, FileLogger.ArchiveLogsCallback callback)
public void clearFiles()