diff --git a/src/components/LogView/LogViewEntry.react.js b/src/components/LogView/LogViewEntry.react.js
index 70a3888786..369ae1b8da 100644
--- a/src/components/LogView/LogViewEntry.react.js
+++ b/src/components/LogView/LogViewEntry.react.js
@@ -22,6 +22,9 @@ const TIMESTAMP_REGEX = [
const isError = str => str[0] === 'E';
+const normalizeText = value =>
+ typeof value === 'string' ? value : JSON.stringify(value) || '';
+
const getLogEntryInfo = str => {
const re = getTimestampRegex();
const timeStampStr = str.match(re) ? str.match(re)[0] : '';
@@ -36,7 +39,7 @@ const getLogEntryInfo = str => {
const getTimestampRegex = () => new RegExp(TIMESTAMP_REGEX, ['i']);
const LogViewEntry = ({ text = '', timestamp }) => {
- const logEntryInfo = getLogEntryInfo(text);
+ const logEntryInfo = getLogEntryInfo(normalizeText(text));
const classes = [styles.entry, logEntryInfo.error ? styles.error : ''];
return (
diff --git a/src/lib/tests/LogViewEntry.test.js b/src/lib/tests/LogViewEntry.test.js
new file mode 100644
index 0000000000..ff4d7ffaa2
--- /dev/null
+++ b/src/lib/tests/LogViewEntry.test.js
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016-present, Parse, LLC
+ * All rights reserved.
+ *
+ * This source code is licensed under the license found in the LICENSE file in
+ * the root directory of this source tree.
+ */
+jest.dontMock('../../components/LogView/LogViewEntry.react');
+
+import React from 'react';
+import renderer from 'react-test-renderer';
+const LogViewEntry = require('../../components/LogView/LogViewEntry.react').default;
+
+describe('LogViewEntry', () => {
+ it('renders a string log message', () => {
+ const text = 'I2015-09-30T00:36:45.522Z] hello world';
+ const tree = renderer
+ .create()
+ .toJSON();
+ expect(JSON.stringify(tree)).toContain('hello world');
+ });
+
+ it('does not crash when the message is a non-string object', () => {
+ const message = { ok: 0, code: 40352, codeName: 'Location40352', name: 'MongoError' };
+ let tree;
+ expect(() => {
+ tree = renderer
+ .create()
+ .toJSON();
+ }).not.toThrow();
+ expect(JSON.stringify(tree)).toContain('MongoError');
+ });
+});