Conduct non-functional refactoring for EventLogger

- Fixed all javadocs across the class to make them consistent to each
  other;
- Reordered modifiers where needed;
- String literal changed to reflect new name of the class.

Bug: b/243116883
Test: N/A
Change-Id: I27c2deb7d3bdf34bac45603221aaa4378450a999
This commit is contained in:
Alex Dadukin
2022-10-11 13:23:41 +00:00
parent cc85b03a91
commit 183bde5d14

View File

@@ -25,20 +25,32 @@ import java.lang.annotation.RetentionPolicy;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.Locale;
/**
* Logs human-readable events for debugging purposes.
*/
public class EventLogger {
// ring buffer of events to log.
/** Identifies the source of events. */
private final String mTag;
/** Stores the events using a ring buffer. */
private final LinkedList<Event> mEvents;
private final String mTitle;
// the maximum number of events to keep in log
/**
* The maximum number of events to keep in {@code mEvents}.
*
* <p>Calling {@link #log} when the size of {@link #mEvents} matches the threshold will
* cause the oldest event to be evicted.
*/
private final int mMemSize;
public static abstract class Event {
// formatter for timestamps
private final static SimpleDateFormat sFormat = new SimpleDateFormat("MM-dd HH:mm:ss:SSS");
public abstract static class Event {
/** Timestamps formatter. */
private static final SimpleDateFormat sFormat =
new SimpleDateFormat("MM-dd HH:mm:ss:SSS", Locale.US);
private final long mTimestamp;
@@ -114,7 +126,7 @@ public class EventLogger {
* Timestamp information will be automatically added, do not include it.
* @return a string representation of the event that occurred.
*/
abstract public String eventToString();
public abstract String eventToString();
}
public static class StringEvent extends Event {
@@ -133,12 +145,12 @@ public class EventLogger {
/**
* Constructor for logger.
* @param size the maximum number of events to keep in log
* @param title the string displayed before the recorded log
* @param tag the string displayed before the recorded log
*/
public EventLogger(int size, String title) {
public EventLogger(int size, String tag) {
mEvents = new LinkedList<Event>();
mMemSize = size;
mTitle = title;
mTag = tag;
}
public synchronized void log(Event evt) {
@@ -170,7 +182,7 @@ public class EventLogger {
}
public synchronized void dump(PrintWriter pw) {
pw.println("Audio event log: " + mTitle);
pw.println("Events log: " + mTag);
for (Event evt : mEvents) {
pw.println(evt.toString());
}