Skip to content

Commit 09233ff

Browse files
committed
fix failing tests
1 parent c93ebd4 commit 09233ff

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

ratlog/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
1+
# -*- coding: utf8 -*-
22
from __future__ import print_function
33

44
import sys
55

66

7+
try:
8+
str = unicode
9+
except NameError:
10+
pass
11+
12+
713
class Log:
814
writer = sys.stdout.write
915

@@ -16,10 +22,20 @@ def __init__(self, *args, **kwargs):
1622
self.tags = list(args)
1723

1824
def __call__(self, message, fields=None, *tag_args):
25+
tag_args = list(tag_args)
26+
27+
if not isinstance(fields, dict):
28+
if fields:
29+
tag_args.insert(0, fields)
30+
fields = None
31+
1932
if not fields:
2033
fields = {}
2134

22-
tags = self._format_tags(self.tags + list(tag_args))
35+
if not isinstance(message, str):
36+
message = str(message)
37+
38+
tags = self._format_tags(self.tags + tag_args)
2339
message = self._format_message(message)
2440
fields = self._format_fields(fields)
2541

tests/test_ratlog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_unicode_as_message(self):
4242

4343
log(u"\U0001F984")
4444

45-
assert "🦄\n" == output.value
45+
assert u"🦄\n" == output.value
4646

4747
def test_string_as_fields_makes_tags(self):
4848
log = ratlog.Log()

0 commit comments

Comments
 (0)