Merge "Move EventLogger.Event definition to the bottom of the outer class"
This commit is contained in:
@@ -46,6 +46,52 @@ public class EventLogger {
|
||||
*/
|
||||
private final int mMemSize;
|
||||
|
||||
/**
|
||||
* Constructor for logger.
|
||||
* @param size the maximum number of events to keep in log
|
||||
* @param tag the string displayed before the recorded log
|
||||
*/
|
||||
public EventLogger(int size, String tag) {
|
||||
mEvents = new LinkedList<Event>();
|
||||
mMemSize = size;
|
||||
mTag = tag;
|
||||
}
|
||||
|
||||
public synchronized void log(Event evt) {
|
||||
if (mEvents.size() >= mMemSize) {
|
||||
mEvents.removeFirst();
|
||||
}
|
||||
mEvents.add(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a string-based event to the log, and print it to logcat as info.
|
||||
* @param msg the message for the logs
|
||||
* @param tag the logcat tag to use
|
||||
*/
|
||||
public synchronized void loglogi(String msg, String tag) {
|
||||
final Event event = new StringEvent(msg);
|
||||
log(event.printLog(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #loglogi(String, String)} but specifying the logcat type
|
||||
* @param msg the message for the logs
|
||||
* @param logType the type of logcat entry
|
||||
* @param tag the logcat tag to use
|
||||
*/
|
||||
public synchronized void loglog(String msg, @Event.LogType int logType, String tag) {
|
||||
final Event event = new StringEvent(msg);
|
||||
log(event.printLog(logType, tag));
|
||||
}
|
||||
|
||||
public synchronized void dump(PrintWriter pw) {
|
||||
pw.println("Events log: " + mTag);
|
||||
for (Event evt : mEvents) {
|
||||
pw.println(evt.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Event {
|
||||
|
||||
/** Timestamps formatter. */
|
||||
@@ -141,50 +187,4 @@ public class EventLogger {
|
||||
return mMsg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for logger.
|
||||
* @param size the maximum number of events to keep in log
|
||||
* @param tag the string displayed before the recorded log
|
||||
*/
|
||||
public EventLogger(int size, String tag) {
|
||||
mEvents = new LinkedList<Event>();
|
||||
mMemSize = size;
|
||||
mTag = tag;
|
||||
}
|
||||
|
||||
public synchronized void log(Event evt) {
|
||||
if (mEvents.size() >= mMemSize) {
|
||||
mEvents.removeFirst();
|
||||
}
|
||||
mEvents.add(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a string-based event to the log, and print it to logcat as info.
|
||||
* @param msg the message for the logs
|
||||
* @param tag the logcat tag to use
|
||||
*/
|
||||
public synchronized void loglogi(String msg, String tag) {
|
||||
final Event event = new StringEvent(msg);
|
||||
log(event.printLog(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #loglogi(String, String)} but specifying the logcat type
|
||||
* @param msg the message for the logs
|
||||
* @param logType the type of logcat entry
|
||||
* @param tag the logcat tag to use
|
||||
*/
|
||||
public synchronized void loglog(String msg, @Event.LogType int logType, String tag) {
|
||||
final Event event = new StringEvent(msg);
|
||||
log(event.printLog(logType, tag));
|
||||
}
|
||||
|
||||
public synchronized void dump(PrintWriter pw) {
|
||||
pw.println("Events log: " + mTag);
|
||||
for (Event evt : mEvents) {
|
||||
pw.println(evt.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user