public class FileLogger
extends java.lang.Object
Constructor and Description |
---|
FileLogger(Context context,
java.lang.String componentName)
Parameterized constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addLogLine(java.lang.String logLine)
Writes a log line to the file.
|
void |
addLogLines(java.util.List<java.lang.String> logLines)
Writes a list of log lines to the file.
|
void |
addLogLines(java.lang.String[] logLines)
Writes an array of log lines to the file.
|
void |
flushLog()
Flushes the log file and resets it to its original state.
|
int |
getMaxSize()
Returns the maximum number of log lines that can be stored in this file.
|
int |
getSize()
Returns the number of log lines stored in this file.
|
java.lang.String[] |
readAndRemoveFileAsArray()
Returns all log lines stored in FIFO and removes them as they are being read.
|
java.util.List<java.lang.String> |
readAndRemoveFileAsList()
Returns all log lines stored in FIFO and removes them as they are being read.
|
java.lang.String[] |
readAndRemoveLogLinesAsArray(int numLines)
Returns an array of log lines in FIFO and removes them as they are being read.
|
java.util.List<java.lang.String> |
readAndRemoveLogLinesAsList(int numLines)
Returns a list of log lines in FIFO and removes them as they are being read.
|
java.lang.String |
readLogLine()
Returns a single log line in FIFO.
|
void |
removeLogLine()
Removes the first log line in the file.
|
void |
removeLogLines(int numLines)
Removes the specified number of log lines from the file in FIFO.
|
static void |
resetFileLoggerPrefs(Context context)
Resets the stored file logger prefs.
|
void |
setMaxSize(int size)
Sets the maximum number of log lines that can be stored in this file.
|
public FileLogger(Context context, java.lang.String componentName) throws java.io.IOException
context
- Context.componentName
- Component name.java.io.IOException
- If file initialization was unsuccessful.public void flushLog()
public int getSize()
public int getMaxSize()
public void setMaxSize(int size)
size
- Maximum number of log lines.public void addLogLine(java.lang.String logLine)
logLine
- Log line.public void addLogLines(java.util.List<java.lang.String> logLines)
logLines
- Log lines.public void addLogLines(java.lang.String[] logLines)
logLines
- Log lines.public java.lang.String readLogLine()
public java.util.List<java.lang.String> readAndRemoveLogLinesAsList(int numLines)
numLines
- Number of lines to be read.public java.lang.String[] readAndRemoveLogLinesAsArray(int numLines)
numLines
- Number of lines to be read.public java.util.List<java.lang.String> readAndRemoveFileAsList()
public java.lang.String[] readAndRemoveFileAsArray()
public void removeLogLine()
public void removeLogLines(int numLines)
numLines
- Number of log lines.public static void resetFileLoggerPrefs(Context context)
context
- Context.