Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,51 +42,69 @@ public interface Adapter {
static class LegacyImpl implements Adapter {

@Override
public void i(String tag, String message) {
Log.i(tag, message);
appendLog(tag + ": " + message);
public void i(final String tag, final String message) {
if (tag != null && message != null) {
Log.i(tag, message);
appendLog(tag + ": " + message);
}
}

@Override
public void d(String tag, String message) {
Log.d(tag, message);
appendLog(tag + ": " + message);
public void d(final String tag, final String message) {
if (tag != null && message != null) {
Log.d(tag, message);
appendLog(tag + ": " + message);
}
}

@Override
public void d(String tag, String message, Exception e) {
Log.d(tag, message, e);
appendLog(tag + ": " + message + " Exception: " + Arrays.toString(e.getStackTrace()));
public void d(final String tag, final String message, Exception e) {
if (tag != null && message != null && e != null) {
Log.d(tag, message, e);
StackTraceElement[] trace = e.getStackTrace();
appendLog(tag + ": " + message + " Exception: " + Arrays.toString(trace));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you separated this? Could also still be inline, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean my "separation" vs "inline"?

Copy link
Contributor Author

@ezaquarii ezaquarii Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger implementation in Log_OC was extracted so we can use new logger implementation without re-writing the world. The application swaps this implementation for it's own Logger just after start, but the legacy code (other apps?) can still use the old implementation.

nextcloud/android#4275

I suspect that something tried to log before the logger implementation was swapped, and it wrote null causing an NPE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it was:
Arrays.toString(e.getStackTrace()))

now it is:
StackTraceElement[] trace = e.getStackTrace();
Arrays.toString(trace)

}
}

@Override
public void e(String tag, String message) {
Log.e(tag, message);
appendLog(tag + ": " + message);
public void e(final String tag, final String message) {
if (tag != null && message != null) {
Log.e(tag, message);
appendLog(tag + ": " + message);
}
}

@Override
public void e(String tag, String message, Throwable t) {
Log.e(tag, message, t);
appendLog(tag + ": " + message + " Exception: " + Arrays.toString(t.getStackTrace()));
public void e(final String tag, final String message, final Throwable t) {
if (tag != null && message != null && t != null) {
Log.e(tag, message, t);
StackTraceElement[] trace = t.getStackTrace();
appendLog(tag + ": " + message + " Exception: " + Arrays.toString(trace));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

}
}

@Override
public void v(String tag, String message) {
Log.v(tag, message);
appendLog(tag + ": " + message);
public void v(final String tag, final String message) {
if (tag != null && message != null) {
Log.v(tag, message);
appendLog(tag + ": " + message);
}
}

@Override
public void w(String tag, String message) {
Log.w(tag, message);
appendLog(tag + ": " + message);
public void w(final String tag, final String message) {
if (tag != null && message != null) {
Log.w(tag, message);
appendLog(tag + ": " + message);
}
}

@Override
public void wtf(String tag, String message) {
Log.wtf(tag, message);
appendLog(tag + ": " + message);
public void wtf(final String tag, final String message) {
if (tag != null && message != null) {
Log.wtf(tag, message);
appendLog(tag + ": " + message);
}
}
}

Expand Down