On Feb 1, 2011, at 11:38 AM, Massimo Di Pierro wrote:
> 
> I'd like to hear more pros and cons about this from other users.

Good idea.

I'd make one change, though: define a separate ticket logger:

logger_ticket = logging.getLogger("web2py.ticket")

...and use it for this purpose. Perhaps add an explicit entry for it in 
logging.example.conf. That way ticket logging can be controlled independently 
of "real" web2py errors.

Is there a reason perhaps to log a little more information? The application, at 
least? That won't always be obvious from the traceback. Also the request URL is 
living somewhere in request.env (request.env.request_uri IIRC); might be useful.

> 
> massimo
> 
> On Feb 1, 11:19 am, Jim Karsten <[email protected]> wrote:
>> On my development server, I log errors to syslog so they are
>> accessible from a single location. Web2py tickets present a problem
>> since they are not logged. I could configure syslog to access errors
>> from the ticket error file, but it contains more information than I
>> need and the text isn't in a suitable format.
>> 
>> I added three lines to the RestrictedError class log() method in gluon/
>> restricted.py. The traceback message of a ticket is then logged quite
>> nicely.
>> 
>>     def log(self, request):
>>         ...
>> 
>>             ticket_storage = TicketStorage(db=request.tickets_db)
>>             ticket_storage.store(request, f, d)
>> =>          for line in str(self.traceback).split("\n"):
>> =>              if len(line.strip()) > 1:
>> =>                  logger.error(line.strip())
>>             return '%s/%s' % (a, f)
>>         except:
>>             logger.error(self.traceback)
>>             return None
>> 
>> Is there any interest in adding that to the source code?
>> 
>> Also, when I first tested this, I copied the
>> logger.error(self.traceback) line from the except clause to log the
>> ticket message. It only logged the first line. The message logged is:
>> "Traceback (most recent call last):" which isn't much use. Possibly a
>> for loop similar to what I used above would improve that.
>> 
>> Regards,
>> Jim Karsten


Reply via email to