Skip to content

Commit

Permalink
Fixes #24. No longer throw exception when object is logged. Added uni…
Browse files Browse the repository at this point in the history
…t test.
  • Loading branch information
RobertStewart committed Jan 9, 2015
1 parent aecbfe3 commit 7a70433
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/log4mongo/LoggingEventBsonifierImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public DBObject bsonify(final LoggingEvent loggingEvent) {
result.put(KEY_TIMESTAMP, new Date(loggingEvent.getTimeStamp()));
nullSafePut(result, KEY_LEVEL, loggingEvent.getLevel().toString());
nullSafePut(result, KEY_THREAD, loggingEvent.getThreadName());
nullSafePut(result, KEY_MESSAGE, loggingEvent.getMessage());
nullSafePut(result, KEY_MESSAGE, loggingEvent.getRenderedMessage());
nullSafePut(result, KEY_LOGGER_NAME, bsonifyClassName(loggingEvent.getLoggerName()));

addMDCInformation(result, loggingEvent.getProperties());
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/log4mongo/TestMongoDbAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ public void testHostInfoRecords() throws Exception {
assertEquals(ManagementFactory.getRuntimeMXBean().getName(), hostinfo.get("process"));
}

@Test
/**
* Added to verify fix to GitHub issue #24.
*/
public void testLogObject() throws Exception {
Object object = new Object();

assertEquals(0L, countLogEntries());
log.error(object);
assertEquals(1L, countLogEntries());
}

private long countLogEntries() {
return (collection.getCount());
}
Expand Down

0 comments on commit 7a70433

Please sign in to comment.