LocalLogpublic class LocalLog extends Object Helper class for logging serious issues, which also keeps a small
snapshot of the logged events that can be printed later, such as part
of a system service's dumpsys output. |
Fields Summary |
---|
private final String | mTag | private final int | mMaxLines | private final ArrayList | mLines |
Constructors Summary |
---|
public LocalLog(String tag)
mTag = tag;
|
Methods Summary |
---|
public boolean | dump(java.io.PrintWriter pw, java.lang.String header, java.lang.String prefix)
synchronized (mLines) {
if (mLines.size() <= 0) {
return false;
}
if (header != null) {
pw.println(header);
}
for (int i=0; i<mLines.size(); i++) {
if (prefix != null) {
pw.print(prefix);
}
pw.println(mLines.get(i));
}
return true;
}
| public void | w(java.lang.String msg)
synchronized (mLines) {
Slog.w(mTag, msg);
if (mLines.size() >= mMaxLines) {
mLines.remove(0);
}
mLines.add(msg);
}
|
|