Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
Merge 81aa3f1 into b8eade3
Browse files Browse the repository at this point in the history
  • Loading branch information
jayahariv committed Feb 7, 2019
2 parents b8eade3 + 81aa3f1 commit 0a38e27
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,41 @@ public void run() {
}
});
}

@Test
public void testWriteLogWithError() {
final File path = new File(
context.getCacheDir().getAbsolutePath(),
"testLogWithError"
);
final String logDirectory = emptyDirectory(path.getAbsolutePath());
LogFileConfiguration config = new LogFileConfiguration(logDirectory)
.setUsePlaintext(true);
testWithConfiguration(LogLevel.DEBUG, config, new Runnable() {
@Override
public void run() {
String uuid = UUID.randomUUID().toString();
String message = "test message";
CouchbaseLiteException error = new CouchbaseLiteException(uuid);
Log.v(LogDomain.DATABASE.toString(), message, error);
Log.i(LogDomain.DATABASE.toString(), message, error);
Log.w(LogDomain.DATABASE.toString(), message, error);
Log.e(LogDomain.DATABASE.toString(), message, error);
Log.d(LogDomain.DATABASE.toString(), message, error);
try {
for (File log : path.listFiles()) {
byte[] b = new byte[(int) log.length()];
FileInputStream fileInputStream = new FileInputStream(log);
fileInputStream.read(b);
String contents = new String(b, StandardCharsets.US_ASCII);
assertTrue(contents.contains(uuid));
}
} catch(Exception e) {
fail("Exception during test callback " + e.toString());
}
}
});
}
//endregion

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static void d(String tag, String msg) {
* @param tr An exception to log
*/
public static void d(String tag, String msg, Throwable tr) {
v(tag, "Exception: %s", tr.toString());
d(tag, "Exception: %s", tr.toString());
}

/**
Expand Down

0 comments on commit 0a38e27

Please sign in to comment.