def METHOD_NAME(self, text):
    if not self.enabled:
        return text
    last = 0
    while True:
        idx = text.find("\n", last)
        if idx == -1:
            if len(self.buffer) < 4096:
                self.buffer += text[last:]
            break
        line = text[last:idx]
        if self.buffer:
            line = self.buffer + line
            self.buffer = ""
        last = idx + 1
        # Output each trace on a separate line below ours
        # Logic identical to https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor_base/logger.py#L131
        for m in re.finditer(self.pcaddr_re, line):
            if m is None:
                continue
            trace = self.get_backtrace(m)
            if len(trace) != "":
                text = text[: last] + trace + text[last :]
                last += len(trace)
    return text