{"id":7872,"date":"2024-03-14T07:00:04","date_gmt":"2024-03-14T10:00:04","guid":{"rendered":"https:\/\/blog.botcity.dev\/?p=7872"},"modified":"2024-03-13T21:51:27","modified_gmt":"2024-03-14T00:51:27","slug":"logs-em-python-para-automacao-rpa-exemplo","status":"publish","type":"post","link":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/","title":{"rendered":"Logs em Python para automa\u00e7\u00e3o RPA [+exemplo]"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Logs s\u00e3o cruciais, pois ajudam no gerenciamento da aplica\u00e7\u00e3o, nos permitindo ter insights sobre o comportamento da aplica\u00e7\u00e3o, os erros, as exce\u00e7\u00f5es e quais foram as tarefas realizadas. No contexto de automa\u00e7\u00e3o RPA, a integra\u00e7\u00e3o de logs \u00e9 essencial para ajudar na transpar\u00eancia e proporcionar suporte para solucionar problemas de forma eficiente. Neste artigo, exploraremos o uso de logs em automa\u00e7\u00f5es RPA, destacando a import\u00e2ncia de sua implementa\u00e7\u00e3o e exemplos de como fazer isso com Python, uma linguagem de programa\u00e7\u00e3o de grande import\u00e2ncia nessa \u00e1rea de desenvolvimento.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Logs em Python<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Logs em Python pode ser um importante apoio na hora de desenvolver a sua automa\u00e7\u00e3o RPA, visto que a linguagem Python pode ser uma escolha inteligente, devido a popularidade e simplicidade da linguagem, al\u00e9m do vasto suporte e disponibilidade de bibliotecas e frameworks que podem facilitar o processo de desenvolvimento.<\/span><\/p>\n<p><b>Saiba mais sobre as vantagens do Python para RPA:<\/b> <a href=\"https:\/\/blog.botcity.dev\/pt-br\/2023\/05\/05\/comparacao-vantagens-python-rpa-vs-low-code-rpa\/\"><span style=\"font-weight: 400;\">compara\u00e7\u00e3o de Python RPA vs Low-code<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Log pode ser um registro cronol\u00f3gico de a\u00e7\u00f5es e eventos que podem acontecer dentro da sua automa\u00e7\u00e3o. Esse mesmo log pode ser de diversos tipos e at\u00e9 mesmo retornar informa\u00e7\u00f5es que sejam necess\u00e1rias para a compreens\u00e3o do que estava acontecendo naquele determinado momento e o motivo.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Tipos de Logs em RPA<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Logs em RPA podem variar, de acordo com a realidade do neg\u00f3cio. Por isso \u00e9 importante entender quais s\u00e3o os <\/span><a href=\"https:\/\/blog.botcity.dev\/pt-br\/2023\/07\/10\/quais-tipos-de-logs-considerar-na-sua-automacao-python-rpa-como-gerencia-los-parte-um\/\"><span style=\"font-weight: 400;\">tipos de logs<\/span><\/a><span style=\"font-weight: 400;\"> que seu time precisa considerar para a automa\u00e7\u00e3o:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Logs de execu\u00e7\u00e3o: <\/b><span style=\"font-weight: 400;\">Esses logs referem-se ao que est\u00e1 sendo executado no c\u00f3digo desenvolvido para seu projeto RPA. Podem ser, por exemplo, as \u201cexceptions\u201d, que s\u00e3o os erros t\u00e9cnicos que aconteceram;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Logs de seguran\u00e7a:<\/b><span style=\"font-weight: 400;\"> Esses logs t\u00eam contexto mais espec\u00edfico sobre a seguran\u00e7a da sua automa\u00e7\u00e3o, pois ela tamb\u00e9m \u00e9 um projeto de software e \u00e9 importante considerar a qualidade e seguran\u00e7a do c\u00f3digo e das informa\u00e7\u00f5es trafegadas em cada etapa de execu\u00e7\u00e3o;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Logs relacionados ao neg\u00f3cio: <\/b><span style=\"font-weight: 400;\">Esses logs t\u00eam contexto do processo que est\u00e1 sendo executado pelo rob\u00f4, contendo informa\u00e7\u00f5es como qual tarefa foi executada, em qual etapa o rob\u00f4 est\u00e1 em determinado momento, quais s\u00e3o os dados etc.;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Entre outros.<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-weight: 400;\">Estrutura de logs em Python para automa\u00e7\u00e3o RPA<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A estrutura desses logs podem variar de acordo com a necessidade e os requisitos do neg\u00f3cio a ser atendido. Por\u00e9m \u00e9 importante ter pelo menos a data e hor\u00e1rio do ocorrido, a mensagem correspondente ao evento, alguma identifica\u00e7\u00e3o que tenha rela\u00e7\u00e3o com o contexto, entre outros.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Como desenvolver e consultar os logs em RPA?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Agora vamos para a parte pr\u00e1tica. Nos pr\u00f3ximos t\u00f3picos, vamos acompanhar um exemplo de como desenvolver seus logs utilizando o <\/span><a href=\"https:\/\/github.com\/botcity-dev\/botcity-framework-core-python\"><span style=\"font-weight: 400;\">framework Python da BotCity<\/span><\/a><span style=\"font-weight: 400;\"> e como disponibilizar seus logs para serem acompanhados pelo seu time e sua gest\u00e3o, utilizando o <\/span><a href=\"https:\/\/documentation.botcity.dev\/maestro\/features\/logs\/\"><span style=\"font-weight: 400;\">BotCity Orquestrador<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">No Orquestrador voc\u00ea pode criar logs independentemente das outras <\/span><a href=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/01\/12\/arquitetura-de-automacao\/\"><span style=\"font-weight: 400;\">entidades da arquitetura das automa\u00e7\u00f5es<\/span><\/a><span style=\"font-weight: 400;\">. E para conect\u00e1-la ao nosso rob\u00f4, podemos utilizar o <\/span><a href=\"https:\/\/documentation.botcity.dev\/maestro\/maestro-sdk\/log\/\"><span style=\"font-weight: 400;\">BotCity Maestro SDK<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Exemplo de rob\u00f4 para desenvolver os logs<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Como exemplo, vamos utilizar um rob\u00f4 desenvolvido em Selenium e Python que realiza login na p\u00e1gina <\/span><a href=\"https:\/\/practicetestautomation.com\/practice-test-login\/\"><span style=\"font-weight: 400;\">Practice Test Automation<\/span><\/a><span style=\"font-weight: 400;\">. O rob\u00f4 dever\u00e1 abrir a p\u00e1gina, fazer o login, confirmar que o login aconteceu e, em seguida, fazer o logout e confirmar que funcionou. Caso queira seguir o mesmo exemplo, crie uma pasta no seu computador e, dentro dela, adicione:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">um arquivo chamado requirements.txt;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">um arquivo chamado bot.py;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">o <\/span><a href=\"https:\/\/documentation.botcity.dev\/tutorials\/python-automations\/web\/#downloading-the-webdriver\"><span style=\"font-weight: 400;\">webdriver<\/span><\/a> <span style=\"font-weight: 400;\">de acordo com o seu navegador.<\/span><\/li>\n<\/ul>\n<p><b>Arquivo requirements.txt com as depend\u00eancias e bibliotecas:<\/b><\/p>\n<pre>selenium==4.10.0 \r\nwebdriver-manager==3.8.5<\/pre>\n<p><b>Arquivo bot.py com o c\u00f3digo principal:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">from time import sleep<\/span>\r\n\r\n<span style=\"font-weight: 400;\">from selenium import webdriver<\/span>\r\n<span style=\"font-weight: 400;\">from selenium.webdriver.common.by import By<\/span>\r\n<span style=\"font-weight: 400;\">from selenium.webdriver.firefox.service import Service<\/span>\r\n\r\n\r\n<span style=\"font-weight: 400;\"># using as constants for example only\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"># in a real scenario, this should be passed as parameters or using credentials feature<\/span>\r\n<span style=\"font-weight: 400;\">USERNAME = \"student\"<\/span>\r\n<span style=\"font-weight: 400;\">PASSWORD = \"Password123\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">def main():<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0try:<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# set WebDriver path<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0service = Service(executable_path=r\"geckodriver.exe\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# create a bot instance<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot = webdriver.Firefox(service=service)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# access the page Practice Test Automation<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.get(\"https:\/\/practicetestautomation.com\/practice-test-login\/\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the element input to add username<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_username = bot.find_element(By.ID, \"username\")<\/span>\r\n<span style=\"font-weight: 400;\">\r\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# add the username<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_username.send_keys(USERNAME)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the password element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_password = bot.find_element(By.ID, \"password\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# add the password<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_password.send_keys(PASSWORD)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the button element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_button = bot.find_element(By.ID, \"submit\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# click on the button<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_button.click()<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# wait 3 seconds to ensure that the page opened<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sleep(3)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the login confirmation<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logged = bot.find_element(By.CSS_SELECTOR, \".post-title\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print confirmation text<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(logged.text)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the logout button element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logout = bot.find_element(By.CSS_SELECTOR, \".wp-block-button__link\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# click on the button<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logout.click()<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the login title to ensure that the logout finished<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.find_element(By.CSS_SELECTOR, \"#login &gt; h2:nth-child(1)\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0except Exception as ex:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the element with the error message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0error_alert = bot.find_element(By.ID, \"error\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print the error message and stacktrace<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(error_alert.text)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(ex)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0finally:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# close the browser<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.quit()<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print the message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(\"Finally\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">if __name__ == \"__main__\":<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0main()<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Antes de executar o c\u00f3digo, lembre-se de que voc\u00ea deve instalar as depend\u00eancias com o seguinte comando no seu terminal, dentro da pasta do projeto:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">python -m pip install --upgrade -r requirements.txt<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Para que voc\u00ea possa ter usu\u00e1rio e senha protegidos para utilizar na sua automa\u00e7\u00e3o, conforme indicado nos coment\u00e1rios do c\u00f3digo, siga as instru\u00e7\u00f5es da <\/span><a href=\"https:\/\/documentation.botcity.dev\/maestro\/features\/credentials\/\"><span style=\"font-weight: 400;\">documenta\u00e7\u00e3o sobre credenciais<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Como adicionar o framework da BotCity ao projeto Selenium<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Voc\u00ea pode fazer a instala\u00e7\u00e3o conforme o comando a seguir:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">pip install botcity-maestro-sdk<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">No arquivo das depend\u00eancias, o requirements.txt, vamos adicionar a biblioteca: botcity-maestro-sdk. E no c\u00f3digo do arquivo bot.py, vamos adicionar a seguinte importa\u00e7\u00e3o:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">from botcity.maestro import *<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">No c\u00f3digo principal, do arquivo bot.py, vamos criar a inst\u00e2ncia do BotCity Maestro SDK:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">def main():<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0# instantiating the Maestro SDK<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0maestro = BotMaestroSDK.from_sys_args()<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0execution = maestro.get_execution()<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u2026<\/span><\/pre>\n<h3><span style=\"font-weight: 400;\">Como criar um log<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Vamos come\u00e7ar essa etapa, criando o log dentro do BotCity Orquestrador. No menu localizado na lateral esquerda da tela, identifique a categoria \u201cAutomation Control\u201d. Nela, teremos a op\u00e7\u00e3o \u201cExecution Log\u201d.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7879\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/1-execution-log-menu\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu.png\" data-orig-size=\"1907,892\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"1 &amp;#8211; execution log menu\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu-1024x479.png\" class=\"aligncenter wp-image-7879 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu.png\" alt=\"Tela de in\u00edcio do BotCity Orquestrador, com destaque no menu da lateral esquerda, mostrando a op\u00e7\u00e3o &quot;Execution Logs&quot;.\" width=\"1907\" height=\"892\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu.png 1907w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu-300x140.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu-1024x479.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu-1536x718.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-execution-log-menu-1200x561.png 1200w\" sizes=\"auto, (max-width: 1907px) 100vw, 1907px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Ao entrar na op\u00e7\u00e3o \u201cExecution log\u201d, clique em \u201cnew log\u201d:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7881\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/2-new-log\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log.png\" data-orig-size=\"1690,207\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"2 &amp;#8211; new log\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log-1024x125.png\" class=\"aligncenter wp-image-7881 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log.png\" alt=\"Print com foco na tela Execution Log, apontando no lado direito para o bot\u00e3o &quot;New Log&quot;.\" width=\"1690\" height=\"207\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log.png 1690w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log-300x37.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log-1024x125.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log-1536x188.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-new-log-1200x147.png 1200w\" sizes=\"auto, (max-width: 1690px) 100vw, 1690px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Ap\u00f3s isso, vamos preencher as informa\u00e7\u00f5es solicitadas e adicionar as colunas necess\u00e1rias para nosso projeto e, ao final, clicar no bot\u00e3o \u201ccreate log\u201d. Neste caso, adicionamos a coluna \u201cusername\u201d com o nome \u201cUser\u201d e tamanho de 200 caracteres e tamb\u00e9m a coluna \u201cmessage\u201d com o nome \u201cMessage\u201d e tamanho de 500 caracteres. Ambas as colunas dever\u00e3o ficar vis\u00edveis.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7883\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/3-create-log\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log.png\" data-orig-size=\"1911,899\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"3 &amp;#8211; create log\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log-1024x482.png\" class=\"aligncenter wp-image-7883 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log.png\" alt=\"Tela de cria\u00e7\u00e3o do log solicitando as informa\u00e7\u00f5es descritas no trecho acima do texto do artigo.\" width=\"1911\" height=\"899\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log.png 1911w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log-300x141.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log-1024x482.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log-1536x723.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/3-create-log-1200x565.png 1200w\" sizes=\"auto, (max-width: 1911px) 100vw, 1911px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">A coluna \u201cDate\u201d \u00e9 criada automaticamente, n\u00e3o \u00e9 necess\u00e1rio adicion\u00e1-la. E o log j\u00e1 estar\u00e1 dispon\u00edvel para os <\/span><a href=\"https:\/\/documentation.botcity.dev\/maestro\/features\/repositories\/\"><span style=\"font-weight: 400;\">reposit\u00f3rios<\/span><\/a><span style=\"font-weight: 400;\"> que tiverem acesso a ele:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7885\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/4-log-list\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list.png\" data-orig-size=\"1594,375\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"4 &amp;#8211; log list\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list-1024x241.png\" class=\"aligncenter wp-image-7885 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list.png\" alt=\"Tela da lista de logs, mostrando que o nosso log &quot;login_control&quot; foi criado.\" width=\"1594\" height=\"375\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list.png 1594w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list-300x71.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list-1024x241.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list-1536x361.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-log-list-1200x282.png 1200w\" sizes=\"auto, (max-width: 1594px) 100vw, 1594px\" \/><\/p>\n<p><b>Saiba mais em:<\/b> <a href=\"https:\/\/documentation.botcity.dev\/maestro\/maestro-sdk\/log\/\"><span style=\"font-weight: 400;\">documenta\u00e7\u00e3o de logs<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Agora que j\u00e1 temos o log criado no Orquestrador, precisamos conect\u00e1-lo ao nosso c\u00f3digo, para que, de fato, os logs sejam registrados l\u00e1. Ent\u00e3o em nosso c\u00f3digo principal, vamos adicionar o c\u00f3digo que faz a cria\u00e7\u00e3o do log.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Mas antes disso, vamos tamb\u00e9m configurar a finaliza\u00e7\u00e3o da tarefa para que, quando fa\u00e7amos a execu\u00e7\u00e3o pelo Orquestrador, ele possa entender que a tarefa finalizou com sucesso ou com erro.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Dentro do trecho de c\u00f3digo do try e except, vamos adicionar:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">try:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u2026<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0finish_status = AutomationTaskFinishStatus.SUCCESS<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0finish_message = f'Task with username \"{USERNAME}\" executed with success'<\/span>\r\n\r\n<span style=\"font-weight: 400;\">except Exception as ex:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u2026<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0finish_status = AutomationTaskFinishStatus.FAILED<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0finish_message = f'Task with username \"{USERNAME}\" failed: {error_alert.text}'<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">No c\u00f3digo acima, estamos informando o status da tarefa de acordo com a execu\u00e7\u00e3o do rob\u00f4 e tamb\u00e9m uma mensagem para que seja poss\u00edvel entender o que aconteceu.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">No c\u00f3digo finally, vamos adicionar:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">finally:<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2026<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# finish the task<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0maestro.finish_task(<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0task_id=execution.task_id,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0status=finish_status,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0message=finish_message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# create the log<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0maestro.new_log_entry(<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0activity_label=\"login_control\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0values = {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"username\": USERNAME,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"message\": finish_message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/span><\/pre>\n<h3><span style=\"font-weight: 400;\">Como acompanhar os logs no BotCity Orquestrador<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Caso voc\u00ea queira executar o rob\u00f4 localmente, para que consiga se conectar ao Orquestrador, voc\u00ea precisa adicionar primeiro esse c\u00f3digo para fazer login na ferramenta:<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">maestro.login(<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0server=\"adicione o server aqui\",\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0login=\"adicione o login aqui\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0key=\"adicione a chave aqui\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0)<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Para saber qual \u00e9 o login e a key para esse login ser feito com sucesso, voc\u00ea dever\u00e1 acessar a \u00e1rea chamada \u201cDev Environment\u201d pelo menu da lateral esquerda do seu Orquestrador. Saiba mais em: <\/span><a href=\"https:\/\/documentation.botcity.dev\/maestro\/features\/dev-environment\/\"><span style=\"font-weight: 400;\">documenta\u00e7\u00e3o de Dev Environment<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u26a0\ufe0fLembre-se de que este trecho de c\u00f3digo servir\u00e1 apenas para executar localmente. Voc\u00ea deve retirar esse c\u00f3digo antes de disponibilizar o rob\u00f4 no orquestrador para ser executado automaticamente.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Mas tamb\u00e9m podemos executar dentro do Orquestrador. Para isso, a primeira etapa ser\u00e1 fazer o deploy da sua automa\u00e7\u00e3o seguindo as orienta\u00e7\u00f5es do <\/span><a href=\"https:\/\/documentation.botcity.dev\/tutorials\/orchestrating-your-automation\/\"><span style=\"font-weight: 400;\">tutorial de orquestra\u00e7\u00e3o da sua automa\u00e7\u00e3o<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ap\u00f3s o deploy, crie uma tarefa do tipo teste. Isso porque, caso seja necess\u00e1rio, podemos executar a tarefa novamente sem problemas.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para criar a tarefa, clique na op\u00e7\u00e3o \u201cNew Task\u201d do menu da lateral esquerda do Orquestrador e escolha a sua automa\u00e7\u00e3o. No nosso exemplo, chamamos de bot-login. Ao identific\u00e1-la, clique em \u201cNew Task\u201d, o bot\u00e3o localizado ao final da linha.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7893\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/1-new-task\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task.png\" data-orig-size=\"1918,856\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"1 &amp;#8211; new task\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task-1024x457.png\" class=\"aligncenter wp-image-7893 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task.png\" alt=\"Tela &quot;New task&quot; com o filtro feito a partir do nome do rob\u00f4 &quot;bot-login&quot; para que ele fique em evid\u00eancia para criar a tarefa.\" width=\"1918\" height=\"856\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task.png 1918w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task-300x134.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task-1024x457.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task-1536x686.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/1-new-task-1200x536.png 1200w\" sizes=\"auto, (max-width: 1918px) 100vw, 1918px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Deixe selecionada a checkbox chamada \u201cTest Task\u201d e clique no bot\u00e3o \u201cCreate\u201d:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7896\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/2-task-test\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test.png\" data-orig-size=\"1917,861\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"2 &amp;#8211; task test\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test-1024x460.png\" class=\"aligncenter wp-image-7896 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test.png\" alt=\"Tela da cria\u00e7\u00e3o da tarefa com o formul\u00e1rio para preenchimento. Em destaque mostrando o campo &quot;Task Test&quot; selecionado conforme orientado no texto.\" width=\"1917\" height=\"861\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test.png 1917w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test-300x135.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test-1024x460.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test-1536x690.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/2-task-test-1200x539.png 1200w\" sizes=\"auto, (max-width: 1917px) 100vw, 1917px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">OBS: Lembre-se de deixar o runner vinculado durante o processo de deploy dispon\u00edvel para que consiga executar a tarefa. Mais informa\u00e7\u00f5es no <\/span><a href=\"https:\/\/blog.botcity.dev\/pt-br\/2023\/10\/19\/guia-sobre-como-gerenciar-a-execucao-das-suas-automacoes-conheca-o-botcity-runner\/\"><span style=\"font-weight: 400;\">guia sobre como gerenciar a execu\u00e7\u00e3o das suas automa\u00e7\u00f5es<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ap\u00f3s a execu\u00e7\u00e3o da tarefa, voc\u00ea pode ir at\u00e9 a tela de \u201cExecution Log\u201d, identificar o log criado e verificar se ele foi preenchido corretamente. Aten\u00e7\u00e3o para o filtro de per\u00edodo para garantir que o log que voc\u00ea est\u00e1 procurando poder\u00e1 ser visualizado.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7900\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/4-logs\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs.png\" data-orig-size=\"1916,860\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"4 &amp;#8211; logs\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs-1024x460.png\" class=\"aligncenter wp-image-7900 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs.png\" alt=\"Tela do log criado &quot;login-control&quot; mostrando que um log foi registrado e que a execu\u00e7\u00e3o aconteceu com sucesso.\" width=\"1916\" height=\"860\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs.png 1916w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs-300x135.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs-1024x460.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs-1536x689.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/4-logs-1200x539.png 1200w\" sizes=\"auto, (max-width: 1916px) 100vw, 1916px\" \/><\/p>\n<h3><span style=\"font-weight: 400;\">Como fazer download dos logs<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Para fazer o download dos logs, voc\u00ea pode clicar no bot\u00e3o \u201cExport\u201d, localizado acima do log e escolher um dos formatos dispon\u00edveis: json, csv ou excel.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7904\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/5-export-button\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button.png\" data-orig-size=\"1571,471\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"5 &amp;#8211; export button\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button-1024x307.png\" class=\"aligncenter wp-image-7904 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button.png\" alt=\" Print da tela com foco no log criado e os bot\u00f5es superiores. Em destaque, o bot\u00e3o Export est\u00e1 com seu menu aberto mostrando as op\u00e7\u00f5es json, csv e excel.\" width=\"1571\" height=\"471\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button.png 1571w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button-300x90.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button-1024x307.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button-1536x461.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/5-export-button-1200x360.png 1200w\" sizes=\"auto, (max-width: 1571px) 100vw, 1571px\" \/><\/p>\n<h3><span style=\"font-weight: 400;\">Outras a\u00e7\u00f5es com os logs<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Para fazer edi\u00e7\u00e3o dos logs, delet\u00e1-los ou ainda mud\u00e1-los de reposit\u00f3rio, basta clicar no bot\u00e3o \u201cActions\u201d localizado acima do log e escolher uma das op\u00e7\u00f5es.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"7907\" data-permalink=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/6-actions-button\/\" data-orig-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button.png\" data-orig-size=\"1599,459\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"6 &amp;#8211; actions button\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button-1024x294.png\" class=\"aligncenter wp-image-7907 size-full\" src=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button.png\" alt=\"Print da tela com foco no log criado e os bot\u00f5es superiores. Em destaque, o bot\u00e3o Actions est\u00e1 com seu menu aberto mostrando as op\u00e7\u00f5es edit, delete, move to repostiory.\" width=\"1599\" height=\"459\" srcset=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button.png 1599w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button-300x86.png 300w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button-1024x294.png 1024w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button-1536x441.png 1536w, https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/6-actions-button-1200x344.png 1200w\" sizes=\"auto, (max-width: 1599px) 100vw, 1599px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u26a0\ufe0f Se voc\u00ea deletar o log, esta opera\u00e7\u00e3o apagar\u00e1 todo o hist\u00f3rico de logs e n\u00e3o poder\u00e1 ser revertido.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">C\u00f3digo completo do projeto<\/span><\/h3>\n<pre><span style=\"font-weight: 400;\">from time import sleep<\/span>\r\n\r\n<span style=\"font-weight: 400;\">from selenium import webdriver<\/span>\r\n<span style=\"font-weight: 400;\">from selenium.webdriver.common.by import By<\/span>\r\n<span style=\"font-weight: 400;\">from selenium.webdriver.firefox.service import Service<\/span>\r\n\r\n<span style=\"font-weight: 400;\">from botcity.maestro import *<\/span>\r\n\r\n<span style=\"font-weight: 400;\"># using as constants for example only\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"># in a real scenario, this should be passed as parameters or using credentials feature<\/span>\r\n<span style=\"font-weight: 400;\">USERNAME = \"student\"<\/span>\r\n<span style=\"font-weight: 400;\">PASSWORD = \"Password123\"<\/span>\r\n\r\n<span style=\"font-weight: 400;\">def main():<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0# instantiating the Maestro SDK<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0maestro = BotMaestroSDK.from_sys_args()<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0execution = maestro.get_execution()<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0try:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# set WebDriver path<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0service = Service(executable_path=r\"geckodriver.exe\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# create a bot instance<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot = webdriver.Firefox(service=service)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# access the page Practice Test Automation<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.get(\"https:\/\/practicetestautomation.com\/practice-test-login\/\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the element input to add username<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_username = bot.find_element(By.ID, \"username\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# add the username<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_username.send_keys(USERNAME)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the password element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_password = bot.find_element(By.ID, \"password\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# add the password<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_password.send_keys(PASSWORD)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the button element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_button = bot.find_element(By.ID, \"submit\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# click on the button<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0input_button.click()<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# wait 3 seconds to ensure that the page opened<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sleep(3)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the login confirmation<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logged = bot.find_element(By.CSS_SELECTOR, \".post-title\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print confirmation text<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(logged.text)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the logout button element<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logout = bot.find_element(By.CSS_SELECTOR, \".wp-block-button__link\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# click on the button<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logout.click()<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the login title to ensure that the logout finished<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.find_element(By.CSS_SELECTOR, \"#login &gt; h2:nth-child(1)\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0finish_status = AutomationTaskFinishStatus.SUCCESS<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0finish_message = f'Task with username \"{USERNAME}\" executed with success'<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0except Exception as ex:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search for the element with the error message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0error_alert = bot.find_element(By.ID, \"error\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print the error message and stacktrace<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(error_alert.text)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(ex)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0finish_status = AutomationTaskFinishStatus.FAILED<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0finish_message = f'Task with username \"{USERNAME}\" failed: {error_alert.text}'<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0finally:<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# close the browser<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0bot.quit()<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# print the message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(\"Finally\")<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# finish the task<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0maestro.finish_task(<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0task_id=execution.task_id,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0status=finish_status,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0message=finish_message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# create the log<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0maestro.new_log_entry(<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0activity_label=\"login_control\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0values = {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"username\": USERNAME,<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"message\": finish_message<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">if __name__ == \"__main__\":<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0main()<\/span><\/pre>\n<h2><span style=\"font-weight: 400;\">Quer come\u00e7ar a gerenciar melhor sua automa\u00e7\u00e3o com o uso dos logs?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Para ir mais a fundo neste assunto, te convidamos a participar da nossa comunidade global de RPA, \u00e9 s\u00f3 entrar no nosso <\/span><a href=\"https:\/\/join.slack.com\/t\/communitybotcitydev\/shared_invite\/zt-xt5lu9bq-l2E1gcf9pZgr4UrnIRJMLw\"><span style=\"font-weight: 400;\">Slack<\/span><\/a> <span style=\"font-weight: 400;\">ou ainda entrar em contato pelo nosso <\/span><a href=\"https:\/\/community.botcity.dev\/\"><span style=\"font-weight: 400;\">f\u00f3rum<\/span><\/a><span style=\"font-weight: 400;\">. Qualquer d\u00favida, s\u00f3 chamar a gente! E n\u00e3o esque\u00e7a de<\/span> <a href=\"https:\/\/developers.botcity.dev\/signup\"><span style=\"font-weight: 400;\">criar a sua conta gratuita<\/span><\/a><span style=\"font-weight: 400;\"> para testar as funcionalidades que estamos explorando em nossos conte\u00fados. Ao criar suas automa\u00e7\u00f5es para aprender como utilizar a ferramenta, lembre-se de compartilhar com a comunidade pelo <\/span><a href=\"https:\/\/repository.botcity.dev\/\"><span style=\"font-weight: 400;\">Reposit\u00f3rio de Bots<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Logs s\u00e3o cruciais, pois ajudam no gerenciamento da aplica\u00e7\u00e3o, nos permitindo ter insights sobre o comportamento da aplica\u00e7\u00e3o, os erros, as exce\u00e7\u00f5es e quais foram as tarefas realizadas. No contexto de automa\u00e7\u00e3o RPA, a integra\u00e7\u00e3o de logs \u00e9 essencial para ajudar na transpar\u00eancia e proporcionar suporte para solucionar problemas de forma eficiente. Neste artigo, exploraremos<\/p>\n","protected":false},"author":214060721,"featured_media":7873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[773019],"tags":[],"class_list":["post-7872","post","type-post","status-publish","format-standard","has-post-thumbnail","category-nao-categorizado"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Logs em Python para automa\u00e7\u00e3o RPA<\/title>\n<meta name=\"description\" content=\"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Logs em Python para automa\u00e7\u00e3o RPA\" \/>\n<meta property=\"og:description\" content=\"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog BotCity - Conte\u00fado para Automa\u00e7\u00e3o e Governan\u00e7a\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-14T10:00:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Lorhan Caproni\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lorhan Caproni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/\"},\"author\":{\"name\":\"Lorhan Caproni\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#\\\/schema\\\/person\\\/c70dcd8d50fca4702dc06ce662e0f111\"},\"headline\":\"Logs em Python para automa\u00e7\u00e3o RPA [+exemplo]\",\"datePublished\":\"2024-03-14T10:00:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/\"},\"wordCount\":1525,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/capa-artigo-4.png\",\"articleSection\":[\"N\u00e3o categorizado\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/\",\"url\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/\",\"name\":\"Logs em Python para automa\u00e7\u00e3o RPA\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/capa-artigo-4.png\",\"datePublished\":\"2024-03-14T10:00:04+00:00\",\"description\":\"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/capa-artigo-4.png\",\"contentUrl\":\"https:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/capa-artigo-4.png\",\"width\":1400,\"height\":800,\"caption\":\"duas pessoas ao redor de uma mesa olhando um notebook como se estivessem analisando o que consta na tela.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/2024\\\/03\\\/14\\\/logs-em-python-para-automacao-rpa-exemplo\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Logs em Python para automa\u00e7\u00e3o RPA [+exemplo]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#website\",\"url\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/\",\"name\":\"Blog BotCity\",\"description\":\"Explore o blog BotCity com conte\u00fados para automatizar e governar em Python. Mantenha-se informado e melhore o desempenho tecnol\u00f3gico, a seguran\u00e7a e o ROI da sua empresa.\",\"publisher\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#organization\",\"name\":\"BotCity\",\"url\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"http:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/logo_botcity_2024_black.png\",\"contentUrl\":\"http:\\\/\\\/blog.botcity.dev\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/logo_botcity_2024_black.png\",\"width\":1611,\"height\":384,\"caption\":\"BotCity\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/#\\\/schema\\\/person\\\/c70dcd8d50fca4702dc06ce662e0f111\",\"name\":\"Lorhan Caproni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g\",\"caption\":\"Lorhan Caproni\"},\"description\":\"BotCity Cofounder and CEO\",\"sameAs\":[\"http:\\\/\\\/botcitydev.wordpress.com\"],\"url\":\"https:\\\/\\\/blog.botcity.dev\\\/pt-br\\\/author\\\/lorhanb8c3fbc9af\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Logs em Python para automa\u00e7\u00e3o RPA","description":"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/","og_locale":"pt_BR","og_type":"article","og_title":"Logs em Python para automa\u00e7\u00e3o RPA","og_description":"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.","og_url":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/","og_site_name":"Blog BotCity - Conte\u00fado para Automa\u00e7\u00e3o e Governan\u00e7a","article_published_time":"2024-03-14T10:00:04+00:00","og_image":[{"width":1400,"height":800,"url":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","type":"image\/png"}],"author":"Lorhan Caproni","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Lorhan Caproni","Est. tempo de leitura":"9 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#article","isPartOf":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/"},"author":{"name":"Lorhan Caproni","@id":"https:\/\/blog.botcity.dev\/pt-br\/#\/schema\/person\/c70dcd8d50fca4702dc06ce662e0f111"},"headline":"Logs em Python para automa\u00e7\u00e3o RPA [+exemplo]","datePublished":"2024-03-14T10:00:04+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/"},"wordCount":1525,"commentCount":0,"publisher":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/#organization"},"image":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","articleSection":["N\u00e3o categorizado"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/","url":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/","name":"Logs em Python para automa\u00e7\u00e3o RPA","isPartOf":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#primaryimage"},"image":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","datePublished":"2024-03-14T10:00:04+00:00","description":"Entenda neste artigo o que s\u00e3o logs, qual a sua import\u00e2ncia e como desenvolver com Python para a sua automa\u00e7\u00e3o RPA.","breadcrumb":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#primaryimage","url":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","contentUrl":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","width":1400,"height":800,"caption":"duas pessoas ao redor de uma mesa olhando um notebook como se estivessem analisando o que consta na tela."},{"@type":"BreadcrumbList","@id":"https:\/\/blog.botcity.dev\/pt-br\/2024\/03\/14\/logs-em-python-para-automacao-rpa-exemplo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.botcity.dev\/pt-br\/"},{"@type":"ListItem","position":2,"name":"Logs em Python para automa\u00e7\u00e3o RPA [+exemplo]"}]},{"@type":"WebSite","@id":"https:\/\/blog.botcity.dev\/pt-br\/#website","url":"https:\/\/blog.botcity.dev\/pt-br\/","name":"Blog BotCity","description":"Explore o blog BotCity com conte\u00fados para automatizar e governar em Python. Mantenha-se informado e melhore o desempenho tecnol\u00f3gico, a seguran\u00e7a e o ROI da sua empresa.","publisher":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.botcity.dev\/pt-br\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/blog.botcity.dev\/pt-br\/#organization","name":"BotCity","url":"https:\/\/blog.botcity.dev\/pt-br\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/blog.botcity.dev\/pt-br\/#\/schema\/logo\/image\/","url":"http:\/\/blog.botcity.dev\/wp-content\/uploads\/2025\/09\/logo_botcity_2024_black.png","contentUrl":"http:\/\/blog.botcity.dev\/wp-content\/uploads\/2025\/09\/logo_botcity_2024_black.png","width":1611,"height":384,"caption":"BotCity"},"image":{"@id":"https:\/\/blog.botcity.dev\/pt-br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blog.botcity.dev\/pt-br\/#\/schema\/person\/c70dcd8d50fca4702dc06ce662e0f111","name":"Lorhan Caproni","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/secure.gravatar.com\/avatar\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a4f02f5e361046d8a6d852df16da98ddff27755dc746d7151c3b577231cbf3ba?s=96&d=identicon&r=g","caption":"Lorhan Caproni"},"description":"BotCity Cofounder and CEO","sameAs":["http:\/\/botcitydev.wordpress.com"],"url":"https:\/\/blog.botcity.dev\/pt-br\/author\/lorhanb8c3fbc9af\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/blog.botcity.dev\/wp-content\/uploads\/2024\/03\/capa-artigo-4.png","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pdx8c3-22Y","_links":{"self":[{"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/posts\/7872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/users\/214060721"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/comments?post=7872"}],"version-history":[{"count":20,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/posts\/7872\/revisions"}],"predecessor-version":[{"id":7917,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/posts\/7872\/revisions\/7917"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/media\/7873"}],"wp:attachment":[{"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/media?parent=7872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/categories?post=7872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.botcity.dev\/pt-br\/wp-json\/wp\/v2\/tags?post=7872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}