Added create_tagged_trace_logger helper function
CHERRY PICKED FROM AOSP
Bug: 80476921
Test: python3.5 > logger.create_tagged_trace_logger('Tag')
Change-Id: I4c1da32618a2e67d453a733dbe863cce3e413433
diff --git a/acts/framework/acts/logger.py b/acts/framework/acts/logger.py
index 92f1e5e..2f94f83 100755
--- a/acts/framework/acts/logger.py
+++ b/acts/framework/acts/logger.py
@@ -255,3 +255,17 @@
>>> lambda log_message: return 'string'
"""
return tracelogger.TraceLogger(LoggerAdapter(logging_lambda))
+
+
+def create_tagged_trace_logger(tag=''):
+ """Returns a logger that logs each line with the given prefix.
+
+ Args:
+ tag: The tag of the log line, E.g. if tag == tag123, the output
+ line would be:
+
+ <TESTBED> <TIME> <LOG_LEVEL> [tag123] logged message
+ """
+ def logging_lambda(msg):
+ return '[%s] %s' % (tag, msg)
+ return create_logger(logging_lambda)