Skip to content

Commit 7ea8bdd

Browse files
committed
some logger fixes
1 parent fa8a51d commit 7ea8bdd

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

rever/logger.xsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Logger:
3333
entry['activity'] = activity
3434
with open(self.filename, 'a+') as f:
3535
json.dump(entry, f, sort_keys=True, separators=(',', ':'))
36+
f.write('\n')
3637

3738
def load(self):
3839
"""Loads all of the records from the logfile and returns a list of dicts."""

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
@pytest.fixture
1212
def gitrepo(request):
13-
"""A test fixutre that creates and destroys a git repo in a temporary directory"""
13+
"""A test fixutre that creates and destroys a git repo in a temporary directory.
14+
This will yeild the path to the repo.
15+
"""
1416
cwd = os.getcwd()
1517
name = request.node.name
1618
repo = os.path.join(tempfile.gettempdir(), name)

tests/test_logger.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
"""Tests logger"""
22
import os
33

4+
from rever import vcsutils
45
from rever.logger import Logger
56

67

78
def test_logger(gitrepo):
89
logger = Logger(os.path.join(gitrepo, 'mylog.json'))
910
logger.log('sample message', activity="kenny", category="loggin'")
11+
logger.log('another message', activity="wood", category="chippin'")
1012
entries = logger.load()
11-
assert len(entries) == 1
13+
assert len(entries) == 2
14+
entry = entries[0]
15+
assert entry['message'] == 'sample message'
16+
assert entry['activity'] == 'kenny'
17+
assert entry['category'] == "loggin'"
18+
assert entry['rev'] == vcsutils.current_rev()
19+
entry = entries[1]
20+
assert entry['message'] == 'another message'
21+
assert entry['activity'] == 'wood'
22+
assert entry['category'] == "chippin'"
23+
assert entry['rev'] == vcsutils.current_rev()
24+
assert entries[0]['timestamp'] < entries[1]['timestamp']

0 commit comments

Comments
 (0)