Good points!

So I'd suggest change the last line of my code into:
  app_logging=cache.ram(...)
then web2py framework users can freely choose logging and app_logging
at the same time.

And GAE... mmm... not familiar yet. Perhaps something like this?
if running_on_gae:
  import logging as app_logging # fall back to standard logging
else:
  blah blah # all the code in my previous post


On Sep1, 12:06pm, Richard <richar...@gmail.com> wrote:
> cool example! - I'm using something similar.
> But if it interferes with the logging module and doesn't work on GAE
> maybe it's too intrusive to include in the scaffolding app.
>
> Richard
>
> On Sep 1, 1:13 pm, Iceberg <iceb...@21cn.com> wrote:
>
>
>
> > On Sep1, 2:00am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > It seems to me the scaffolding app is already too heavy. Somebody has
> > > proposed having multiple scaffolding apps.
>
> > > If you make an app with this model and a controller for reading/
> > > searching the logs, I will post it (for now) on appliances as an
> > > example.
>
> > > Massimo
>
> > I like lightweight solution too. So, to keep things simple and stupid,
> > I modified the log_model.py as below, so that user can read logs
> > WITHOUT dedicated controller or action, and user can search log by
> > browser's search function.
>
> > And I think the following log_model.py is small enough (811 bytes) to
> > be included in the scaffolding app. Just drop it into any app, then it
> > will work. On the contrary, make it a sample app on applicances or
> > just mention it in AlterEgo, won't get enough attention.
>
> > The code.
> > # This model file defines some magic to implement app_wide_log.
> > # Do not use "import logging" in your controllers, otherwise you lose
> > the magic.
> > import os
> > app_wide_log = os.path.join( # Does not work on GAE
> >   # so that it can be served ashttp://.../yourapp/static/app.txt
> >   request.folder,'static','app.txt')
> > def _init_log():
> >   import logging,logging.handlers
> >   logger = logging.getLogger(request.application)
> >   logger.setLevel(logging.DEBUG)
> >   handler = logging.handlers.RotatingFileHandler(
> >     app_wide_log,'a',1024*1024,1)
> >   handler.setLevel(logging.DEBUG)
> >   handler.setFormatter(logging.Formatter(
> >     "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message)
> > s"))
> >   logger.addHandler(handler)
> >   return logger
> > logging = cache.ram('app_wide_log',lambda:_init_log
> > (),time_expire=None)
> > # not yet tuned for GAE.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to