<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def log_background_messages(self, name=None):
 """Forwards messages logged on background to Robot Framework log. By default forwards all messages logged by all threads, but can be limited to a certain thread by passing thread's name as an argument. Logged messages are removed from the message storage. """

        with self.lock:
            if name:
                self._log_messages_by_thread(name)
            else:
                self._log_all_messages()