text: Title: Log levels don't work correctly with `robot:flatten`
  Body: This problems was initially reported as part of #4919. It can be reproduced, for example, with this keyword:
  ```robotframework
  *** Keywords ***
  Flatten with levels
      [Tags]    robot:flatten
      Log    INFO 1         INFO
      Log    DEBUG 1        DEBUG
      ${old} =    Set Log Level    DEBUG
      Log    INFO 2         INFO
      Log    DEBUG 2        DEBUG
  ```
  When the above keyword is run, it produces the following messages:
  ```
  15:04:58.453 	INFO 	INFO 1 	
  15:04:58.453 	DEBUG 	DEBUG 1 	
  15:04:58.453 	INFO 	Log level changed from TRACE to DEBUG. 	
  15:04:58.453 	INFO 	${old} = TRACE 	
  15:04:58.453 	INFO 	INFO 2 	
  15:04:58.453 	DEBUG 	DEBUG 2
  ```
  This is obviously wrong. The first debug message shouldn't be there and the message about the level change should show "from INFO to DEBUG".
  