Skip to content

Commit

Permalink
Update binary logging
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Mar 18, 2024
1 parent c9301be commit e855709
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions robotframework_reportportal/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

logger = logging.getLogger(__name__)
DATA_SIGN = '${data} = '
TRUNCATION_SIGN = '...'


def is_binary(iterable: Union[bytes, bytearray, str]) -> bool:
Expand Down Expand Up @@ -113,7 +114,8 @@ def log_message(self, message: Dict) -> None:
if msg.message.startswith(DATA_SIGN):
msg_content = msg.message[len(DATA_SIGN):]
if is_binary(msg_content):
msg.message = DATA_SIGN + str(msg_content.encode('utf-8')[:-4]) # remove trailing '"...'
# remove trailing `'"...`, add `'...`
msg.message = DATA_SIGN + str(msg_content.encode('utf-8')[:-5]) + TRUNCATION_SIGN
logger.debug('ReportPortal - Log Message: {0}'.format(message))
self.service.log(message=msg)

Expand Down Expand Up @@ -259,8 +261,7 @@ def start_keyword(self, name: str, attributes: Dict, ts: Optional[Any] = None) -
:param attributes: Dictionary passed by the Robot Framework
:param ts: Timestamp(used by the ResultVisitor)
"""
kwd = Keyword(name=name, parent_type=self.current_item.type,
attributes=attributes)
kwd = Keyword(name=name, parent_type=self.current_item.type, attributes=attributes)
kwd.rp_parent_item_id = self.parent_id
logger.debug('ReportPortal - Start Keyword: {0}'.format(attributes))
kwd.rp_item_id = self.service.start_keyword(keyword=kwd, ts=ts)
Expand Down

0 comments on commit e855709

Please sign in to comment.