On Thu, Oct 3, 2013 at 9:39 AM, Geo geo.petr...@gmail.com wrote:
Greetings,
I have a controller that generates many log messages. Most of them are
currently used for debugging but some (warnings and errors) are also useful
for users.
Logs are currently handled with a module similar to this:
http://www.web2pyslices.com/slice/show/1416/logging
I have tried attaching a StringIO handler to capture messages to a string
Try different loggers objects, for example:
import logging
import StringIO
def index():
logger = logging.getLogger('%s.%s.%s' % (request.application,
request.controller, request.function))
log_capture_string = StringIO.StringIO()
ch = logging.StreamHandler(log_capture_string)
ch.setLevel(logging.ERROR)
logger.addHandler(ch)
#controller actions
logger.removeHandler(ch)
notifications = log_capture_string.getvalue()
notifications = notifications.split('\n')
log_capture_string.close()
#controller return
return dict(notifications = notifications, myothervars=myothervars)
This works well if I run this controller alone (no other sessions, no other
controllers running at the same time). But as soon as I run something else
concurrently, the handler will capture that too.
Do you know if there is a way to capture the output of a controller when ran
in a specific session?
I thought about mimicking the internal error handler (the one that generates
error tickets) but without success.
Thanks in advance
Geo
--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.