Skip to content

Commit

Permalink
Log browser info and update changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuramachandran committed Mar 16, 2017
1 parent f9c61a9 commit 281714b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* Small UI improvements for search and navigation.
* Fix bug when starting vixen for the first time -- if one added a project it
would not show correctly until vixen was re-launched.

* Fix bug creating a project and immediately deleting tags.
* Fix issue with notifications on firefox.
* Improved test coverage.

0.9
---
Expand Down
3 changes: 3 additions & 0 deletions vixen/html/vixen_ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ <h3 style="margin: 5px;"> View Project: {{viewer.name}}</h3>
},
});

jigna.models.ui.log('Browser information: ' +
navigator.appVersion, 'info');

// The Vue instance.
var data = Object.assign({}, jigna.models);
data.window = window;
Expand Down
24 changes: 24 additions & 0 deletions vixen/tests/test_vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,30 @@ def test_messages(self):
# Then
self.assertEqual(ui.message, ('SUCCESS', 'success', 2))

@mock.patch('vixen.vixen.logger')
def test_vixen_ui_log(self, logger):
# Given
ui = VixenUI()

# When
ui.log('msg', 'info')

# Then
logger.info.assert_called_with('msg')

# When
ui.log('err', 'error')

# Then
logger.error.assert_called_with('err')

# When
ui.log('err', 'blah')

# Then
logger.error.assert_called_with('Unknown message kind: %s', 'blah')
logger.info.assert_called_with('err')

def test_add_remove_project_works(self):
# Given
ui = VixenUI()
Expand Down
11 changes: 11 additions & 0 deletions vixen/vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ def info(self, msg):
self.message = msg, "info", mid
logger.info("INFO: %s", msg)

def log(self, msg, kind='info'):
"""This method is meant to be called from the Javascript side.
"""
if kind == 'info':
logger.info(msg)
elif kind == 'error':
logger.error(msg)
else:
logger.error('Unknown message kind: %s', kind)
logger.info(msg)

def success(self, msg):
mid = self._get_message_id()
self.message = msg, "success", mid
Expand Down

0 comments on commit 281714b

Please sign in to comment.