Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
3225 Vistas

Hi,

I'm starting to develop my first odoo module in odoo 14. For a while I could just print to the standard output using the print() method in Python, but for an unknown reason it started not working anymore. I also tried to use a logger but it doesn't work either.


When it used to work my output was logging me something each time I was moving from a page to another but it doesn't do it anymore. 


Anyone has an idea what could cause this ? 

Thanks !

Avatar
Descartar
Mejor respuesta

Hi,

If you need to use the logger in your functions, first you need to import the logging in your file using import logging

and add the logger;_LOGGER = logging.getLogger(__name__)

by doing these steps you can add logger in you functions by,example:_LOGGER.info("demo print")
-- 


Hope it helps

Avatar
Descartar
Mejor respuesta

Hello, Pierre-Loïc de Schaetzen,


I hope you are doing well.

Please find code in comment. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Descartar

- In the Python Code Below:-

logger = logging.getLogger(__name_)

class<<Add your Class>>:
def <<Your Method Name>>:

<<---Add Your Code--->>

_logger.info(<<Add Message Here>>)

You can also use logger.warning, logger.error, logger.debug, and logger.exception in the added _logger.info.

Autor Mejor respuesta

Thanks for your reply.

Yes I tried to run it in the debug channel as well and it still doesn't work. I changed the logfile to "" so it logs everything to the standard output. Where can I check the code that handles the output ? 

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
may 18
39163
2
mar 15
13131
0
mar 15
4763
0
jul 24
1159
0
ago 18
6880