logging

58 views
Skip to first unread message

Lars

unread,
Aug 31, 2017, 6:38:32 AM8/31/17
to web...@googlegroups.com
Hi,

I have this code in dlogging.py in the modules folder of my app :

import logging
import logging.handlers


def get_configured_logger(name):
   
global logger
    logger
= logging.getLogger(name)
   
if len(logger.handlers) == 0:
        fh
= logging.FileHandler(os.path.join('/'.join(os.path.realpath(__file__).split('/')[:-3]),
                                 
'logs/system.log'))
        formatter
= logging.Formatter('%(asctime)s - %(levelname)s %(message)s')
        fh
.setFormatter(formatter)
        logger
.addHandler(fh)
        logger
.setLevel(logging.DEBUG)
   
return logger

logger
= get_configured_logger('web2py.app.system')

I don't understand why it works in the shell but not from web2py from inside a module class (with from dloggig import logger). Could anybody figure why ?

Thanks

w2p : 2.15.3 py : 3.5.3


Lars

unread,
Aug 31, 2017, 7:47:58 AM8/31/17
to web...@googlegroups.com
The code needs to be in model not in modules cos it needs to be loaded at app start.

Richard Vézina

unread,
Sep 7, 2017, 1:00:27 PM9/7/17
to web2py-users
Hello Lars,


I am looking at logging rigth now a new module and I do my research...

Setting global logger might be one of the main reason of your issue as I guess you are shadowing web2py internal loggin activity???

Richard

On Thu, Aug 31, 2017 at 7:47 AM, Lars <laer...@gmx.fr> wrote:
The code needs to be in model not in modules.

Could anyone explain why ?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages