def _log(self, utterance: Any, direction: str, dialog_id: Optional[Hashable]=None):
if isinstance(utterance, str):<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(utterance, RichMessage):<EOL><INDENT>utterance = utterance.json()<EOL><DEDENT>elif isinstance(utterance, (list, dict)):<EOL><INDENT>utterance = jsonify_data(utterance)<EOL><DEDENT>else:<EOL><INDENT>utterance = str(utterance)<EOL><DEDENT>dialog_id = str(dialog_id) if not isinstance(dialog_id, str) else dialog_id<EOL>if self.log_file.tell() >= self.log_max_size * <NUM_LIT>:<EOL><INDENT>self.log_file.close()<EOL>self.log_file = self._get_log_file()<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>log_msg = {}<EOL>log_msg['<STR_LIT>'] = self._get_timestamp_utc_str()<EOL>log_msg['<STR_LIT>'] = dialog_id<EOL>log_msg['<STR_LIT>'] = direction<EOL>log_msg['<STR_LIT:message>'] = utterance<EOL>log_str = json.dumps(log_msg, ensure_ascii=self.config['<STR_LIT>'])<EOL>self.log_file.write(f'<STR_LIT>')<EOL><DEDENT>except IOError:<EOL><INDENT>log.error('<STR_LIT>')<EOL><DEDENT><DEDENT>
Logs single dialog utterance to current dialog log file.

        Args:
            utterance: Dialog utterance.
            direction: 'in' or 'out' utterance direction.
            dialog_id: Dialog ID.