def create_task_log(self, task_id, case_task_log):
req = self.url + "<STR_LIT>".format(task_id)<EOL>data = {'<STR_LIT>': json.dumps({"<STR_LIT:message>":case_task_log.message})}<EOL>if case_task_log.file:<EOL><INDENT>f = {'<STR_LIT>': (os.path.basename(case_task_log.file), open(case_task_log.file, '<STR_LIT:rb>'), magic.Magic(mime=True).from_file(case_task_log.file))}<EOL>try:<EOL><INDENT>return requests.post(req, data=data,files=f, proxies=self.proxies, auth=self.auth, verify=self.cert)<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise CaseTaskException("<STR_LIT>".format(e))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return requests.post(req, headers={'<STR_LIT:Content-Type>': '<STR_LIT:application/json>'}, data=json.dumps({'<STR_LIT:message>':case_task_log.message}), proxies=self.proxies, auth=self.auth, verify=self.cert)<EOL><DEDENT>except requests.exceptions.RequestException as e:<EOL><INDENT>raise CaseTaskException("<STR_LIT>".format(e))<EOL><DEDENT><DEDENT>
:param task_id: Task identifier
:param case_task_log: TheHive log
:type case_task_log: CaseTaskLog defined in models.py
:return: TheHive log
:rtype: json