On Thu, Mar 10, 2016 at 3:32 AM, Zsolt Ero <zsolt....@gmail.com> 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 <sluggos...@gmail.com>

-- 
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.

Reply via email to