تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
3240 أدوات العرض

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 !

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال

- 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.

الكاتب أفضل إجابة

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 ? 

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مايو 18
39180
2
مارس 15
13147
0
مارس 15
4775
0
يوليو 24
1161
0
أغسطس 18
6898