Thanks a lot for this, I'll have a look how to use tweens, as I haven't been using them so far, but looks clean, I'll try to integrate it.
On Saturday, March 12, 2016 at 4:04:47 AM UTC+1, Mike Orr wrote: > > Here's the code. You can see it's short and simple; half the code is > just to make it more configurable. Usage: > > pyramid_includes = accesslog > > # Settings, all optional > access.format = {response.status_int} {request.method} {request.path_qs} > access.ignore = /fanstatic /_debug_toolbar > access.ignore_usual = true > > > > On Thu, Mar 10, 2016 at 6:46 PM, Mike Orr <slugg...@gmail.com > <javascript:>> wrote: > > On Thu, Mar 10, 2016 at 3:32 AM, Zsolt Ero <zsol...@gmail.com > <javascript:>> wrote: > >> Hi, > >> > >> My first mailing list post, as this really puzzles me. I'd like to use > a > >> short format for displaying HTTP requests in development mode. > >> > >> Before, I used to have this snippet in my Pyramid app's __init__.py: > >> > >> from paste.translogger import TransLogger > >> format = '%(status)s %(REQUEST_METHOD)s %(REQUEST_URI)s' > >> app = TransLogger(app, format=format) > >> return app > >> > >> > >> I'd like to turn this into using an .ini file, however, I cannot > specify the > >> format, as the .ini file syntax needs some kind of escaping, which I > cannot > >> figure out. > >> > >> Here is a try on setting translogger format via .ini file: > >> > >> [filter:translogger] > >> use = egg:Paste#translogger > >> setup_console_handler = False > >> format = %%(status)s %%(REQUEST_METHOD)s %%(REQUEST_URI)s > >> > >> > >> > >> It results in an error: > >> > >> ConfigParser.InterpolationMissingOptionError: Error in file > >> .../development.ini: Bad value substitution: > >> section: [filter:translogger] > >> option : format > >> key : status > >> rawval : %%(status)s > >> > >> > >> What is the right escaping method to set translogger's format via .ini > file? > >> > >> Or if it's not possible to escape it, then I don't get it. Why does > >> translogger has a format option, if you cannot actually enter anything > there > >> via ini? > >> > >> Alembic, for example supports escaping perfectly fine, for example: > >> > >> file_template = > >> > %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d_%%(minute).2d_%%(second).2d_%%(rev)s > > > >> > >> > >> Here is this 4 year old issue in PasteDeploy, I think it's related: > >> > >> > https://bitbucket.org/ianb/pastedeploy/issues/11/there-is-no-way-to-escape-character-in-the > > >> > >> Any ideas how to solve this? > > > > I didn't like using middleware so I made a Pyramid tween that logs > > requests. I don't have the code with me but I can get it tomorrow. > > After calling the applicaiton I make a log message based on the > > response and request. I probably bypassed the % parsing problem by > > using str.format instead, so that I could override the format. My > > logger is called 'access'. > > > > > > -- > > Mike Orr <slugg...@gmail.com <javascript:>> > > > > -- > Mike Orr <slugg...@gmail.com <javascript:>> > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-devel+unsubscr...@googlegroups.com. To post to this group, send email to pylons-devel@googlegroups.com. Visit this group at https://groups.google.com/group/pylons-devel. For more options, visit https://groups.google.com/d/optout.