pyramid-exclog 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ *.egg
2
+ *.egg-info
3
+ *.pyc
4
+ *$py.class
5
+ *.pt.py
6
+ *.txt.py
7
+ *~
8
+ .coverage
9
+ build/
10
+ dist/
11
+ .tox/
12
+ nosetests.xml
13
+ pyramid_exclog/coverage.xml
14
+ env26/
15
+ env27/
@@ -0,0 +1,4 @@
1
+ 0.1
2
+ ---
3
+
4
+ - Initial release.
@@ -0,0 +1,100 @@
1
+ Pylons Project Contributor Agreement
2
+ ====================================
3
+
4
+ The submitter agrees by adding his or her name within the section below named
5
+ "Contributors" and submitting the resulting modified document to the
6
+ canonical shared repository location for this software project (whether
7
+ directly, as a user with "direct commit access", or via a "pull request"), he
8
+ or she is signing a contract electronically. The submitter becomes a
9
+ Contributor after a) he or she signs this document by adding their name
10
+ beneath the "Contributors" section below, and b) the resulting document is
11
+ accepted into the canonical version control repository.
12
+
13
+ Treatment of Account
14
+ ---------------------
15
+
16
+ Contributor will not allow anyone other than the Contributor to use his or
17
+ her username or source repository login to submit code to a Pylons Project
18
+ source repository. Should Contributor become aware of any such use,
19
+ Contributor will immediately by notifying Agendaless Consulting.
20
+ Notification must be performed by sending an email to
21
+ webmaster@agendaless.com. Until such notice is received, Contributor will be
22
+ presumed to have taken all actions made through Contributor's account. If the
23
+ Contributor has direct commit access, Agendaless Consulting will have
24
+ complete control and discretion over capabilities assigned to Contributor's
25
+ account, and may disable Contributor's account for any reason at any time.
26
+
27
+ Legal Effect of Contribution
28
+ ----------------------------
29
+
30
+ Upon submitting a change or new work to a Pylons Project source Repository (a
31
+ "Contribution"), you agree to assign, and hereby do assign, a one-half
32
+ interest of all right, title and interest in and to copyright and other
33
+ intellectual property rights with respect to your new and original portions
34
+ of the Contribution to Agendaless Consulting. You and Agendaless Consulting
35
+ each agree that the other shall be free to exercise any and all exclusive
36
+ rights in and to the Contribution, without accounting to one another,
37
+ including without limitation, the right to license the Contribution to others
38
+ under the Repoze Public License. This agreement shall run with title to the
39
+ Contribution. Agendaless Consulting does not convey to you any right, title
40
+ or interest in or to the Program or such portions of the Contribution that
41
+ were taken from the Program. Your transmission of a submission to the Pylons
42
+ Project source Repository and marks of identification concerning the
43
+ Contribution itself constitute your intent to contribute and your assignment
44
+ of the work in accordance with the provisions of this Agreement.
45
+
46
+ License Terms
47
+ -------------
48
+
49
+ Code committed to the Pylons Project source repository (Committed Code) must
50
+ be governed by the Repoze Public License (http://repoze.org/LICENSE.txt, aka
51
+ "the RPL") or another license acceptable to Agendaless Consulting. Until
52
+ Agendaless Consulting declares in writing an acceptable license other than
53
+ the RPL, only the RPL shall be used. A list of exceptions is detailed within
54
+ the "Licensing Exceptions" section of this document, if one exists.
55
+
56
+ Representations, Warranty, and Indemnification
57
+ ----------------------------------------------
58
+
59
+ Contributor represents and warrants that the Committed Code does not violate
60
+ the rights of any person or entity, and that the Contributor has legal
61
+ authority to enter into this Agreement and legal authority over Contributed
62
+ Code. Further, Contributor indemnifies Agendaless Consulting against
63
+ violations.
64
+
65
+ Cryptography
66
+ ------------
67
+
68
+ Contributor understands that cryptographic code may be subject to government
69
+ regulations with which Agendaless Consulting and/or entities using Committed
70
+ Code must comply. Any code which contains any of the items listed below must
71
+ not be checked-in until Agendaless Consulting staff has been notified and has
72
+ approved such contribution in writing.
73
+
74
+ - Cryptographic capabilities or features
75
+
76
+ - Calls to cryptographic features
77
+
78
+ - User interface elements which provide context relating to cryptography
79
+
80
+ - Code which may, under casual inspection, appear to be cryptographic.
81
+
82
+ Notices
83
+ -------
84
+
85
+ Contributor confirms that any notices required will be included in any
86
+ Committed Code.
87
+
88
+ List of Contributors
89
+ ====================
90
+
91
+ The below-signed are contributors to a code repository that is part of the
92
+ project named "pyramid_exclog". Each below-signed contributor has read,
93
+ understand and agrees to the terms above in the section within this document
94
+ entitled "Pylons Project Contributor Agreement" as of the date beside his or
95
+ her name.
96
+
97
+ Contributors
98
+ ------------
99
+
100
+ - Chris McDonough, 2011/08/11
@@ -0,0 +1,2 @@
1
+ Copyright (c) 2008-2011 Agendaless Consulting and Contributors.
2
+ (http://www.agendaless.com), All Rights Reserved
@@ -0,0 +1,38 @@
1
+ A copyright notice accompanies this license document that identifies
2
+ the copyright holders.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ 1. Redistributions in source code must retain the accompanying
9
+ copyright notice, this list of conditions, and the following
10
+ disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the accompanying
13
+ copyright notice, this list of conditions, and the following
14
+ disclaimer in the documentation and/or other materials provided
15
+ with the distribution.
16
+
17
+ 3. Names of the copyright holders must not be used to endorse or
18
+ promote products derived from this software without prior
19
+ written permission from the copyright holders.
20
+
21
+ 4. If any files are modified, you must cause the modified files to
22
+ carry prominent notices stating that you changed the files and
23
+ the date of any change.
24
+
25
+ Disclaimer
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
28
+ ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31
+ HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
33
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
35
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
37
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38
+ SUCH DAMAGE.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 1.0
2
+ Name: pyramid_exclog
3
+ Version: 0.1
4
+ Summary: A package which logs to a Python logger when an exception is raised by a Pyramid application
5
+ Home-page: http://docs.pylonsproject.org
6
+ Author: Chris McDonough
7
+ Author-email: pylons-devel@googlegroups.com
8
+ License: BSD-derived (http://www.repoze.org/LICENSE.txt)
9
+ Description: ``pyramid_exclog``
10
+ ===================
11
+
12
+ A package which logs exception information when an error occurs in your
13
+ Pyramid application. See the documentation at
14
+ https://docs.pylonsproject.org/projects/pyramid_exclog/dev/ for more
15
+ information.
16
+
17
+ This package currently will not work with any released Pyramid; it requires
18
+ the Pyramid trunk (aka "1.2dev"), available from
19
+ https://github.com/Pylons/pyramid .
20
+
21
+
22
+ 0.1
23
+ ---
24
+
25
+ - Initial release.
26
+
27
+ Keywords: wsgi pylons pyramid mail tween exception handler
28
+ Platform: UNKNOWN
29
+ Classifier: Intended Audience :: Developers
30
+ Classifier: Programming Language :: Python
31
+ Classifier: Framework :: Pylons
32
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
33
+ Classifier: License :: Repoze Public License
@@ -0,0 +1,11 @@
1
+ ``pyramid_exclog``
2
+ ===================
3
+
4
+ A package which logs exception information when an error occurs in your
5
+ Pyramid application. See the documentation at
6
+ https://docs.pylonsproject.org/projects/pyramid_exclog/dev/ for more
7
+ information.
8
+
9
+ This package currently will not work with any released Pyramid; it requires
10
+ the Pyramid trunk (aka "1.2dev"), available from
11
+ https://github.com/Pylons/pyramid .
@@ -0,0 +1,3 @@
1
+ _themes
2
+ _build/
3
+ .static
@@ -0,0 +1,88 @@
1
+ # Makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = sphinx-build
7
+ PAPER =
8
+
9
+ # Internal variables.
10
+ PAPEROPT_a4 = -D latex_paper_size=a4
11
+ PAPEROPT_letter = -D latex_paper_size=letter
12
+ ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
13
+
14
+ .PHONY: help clean html web pickle htmlhelp latex changes linkcheck
15
+
16
+ help:
17
+ @echo "Please use \`make <target>' where <target> is one of"
18
+ @echo " html to make standalone HTML files"
19
+ @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
20
+ @echo " htmlhelp to make HTML files and a HTML help project"
21
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
22
+ @echo " changes to make an overview over all changed/added/deprecated items"
23
+ @echo " linkcheck to check all external links for integrity"
24
+
25
+ clean:
26
+ -rm -rf _build/*
27
+
28
+ html: _themes/
29
+ mkdir -p _build/html _build/doctrees
30
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
31
+ @echo
32
+ @echo "Build finished. The HTML pages are in _build/html."
33
+
34
+ text:
35
+ mkdir -p _build/text _build/doctrees
36
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) _build/text
37
+ @echo
38
+ @echo "Build finished. The HTML pages are in _build/text."
39
+
40
+ pickle:
41
+ mkdir -p _build/pickle _build/doctrees
42
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
43
+ @echo
44
+ @echo "Build finished; now you can process the pickle files or run"
45
+ @echo " sphinx-web _build/pickle"
46
+ @echo "to start the sphinx-web server."
47
+
48
+ web: pickle
49
+
50
+ htmlhelp: _themes
51
+ mkdir -p _build/htmlhelp _build/doctrees
52
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
53
+ @echo
54
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
55
+ ".hhp project file in _build/htmlhelp."
56
+
57
+ latex:
58
+ mkdir -p _build/latex _build/doctrees
59
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
60
+ cp _static/*.png _build/latex
61
+ ./convert_images.sh
62
+ cp _static/latex-warning.png _build/latex
63
+ cp _static/latex-note.png _build/latex
64
+ @echo
65
+ @echo "Build finished; the LaTeX files are in _build/latex."
66
+ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
67
+ "run these through (pdf)latex."
68
+
69
+ changes:
70
+ mkdir -p _build/changes _build/doctrees
71
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
72
+ @echo
73
+ @echo "The overview file is in _build/changes."
74
+
75
+ linkcheck:
76
+ mkdir -p _build/linkcheck _build/doctrees
77
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
78
+ @echo
79
+ @echo "Link check complete; look for any errors in the above output " \
80
+ "or in _build/linkcheck/output.txt."
81
+
82
+ epub:
83
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) _build/epub
84
+ @echo
85
+ @echo "Build finished. The epub file is in _build/epub."
86
+
87
+ _themes:
88
+ git clone git://github.com/Pylons/pylons_sphinx_theme.git _themes
@@ -0,0 +1,11 @@
1
+ .. _pyramid_exclog_api:
2
+
3
+ :mod:`pyramid_exclog` API
4
+ ---------------------------
5
+
6
+ .. automodule:: pyramid_exclog
7
+
8
+ .. autofunction:: includeme
9
+
10
+
11
+
@@ -0,0 +1,210 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # pyramid_exclog documentation build configuration file
4
+ #
5
+ # This file is execfile()d with the current directory set to its containing
6
+ # dir.
7
+ #
8
+ # The contents of this file are pickled, so don't put values in the
9
+ # namespace that aren't pickleable (module imports are okay, they're
10
+ # removed automatically).
11
+ #
12
+ # All configuration values have a default value; values that are commented
13
+ # out serve to show the default value.
14
+
15
+ # If your extensions are in another directory, add it here. If the
16
+ # directory is relative to the documentation root, use os.path.abspath to
17
+ # make it absolute, like shown here.
18
+ #sys.path.append(os.path.abspath('some/directory'))
19
+
20
+ import sys, os
21
+
22
+ parent = os.path.dirname(os.path.dirname(__file__))
23
+ sys.path.append(os.path.abspath(parent))
24
+ wd = os.getcwd()
25
+ os.chdir(parent)
26
+ os.system('%s setup.py test -q' % sys.executable)
27
+ os.chdir(wd)
28
+
29
+ for item in os.listdir(parent):
30
+ if item.endswith('.egg'):
31
+ sys.path.append(os.path.join(parent, item))
32
+
33
+ # General configuration
34
+ # ---------------------
35
+
36
+ # Add any Sphinx extension module names here, as strings. They can be
37
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
38
+ extensions = [
39
+ 'sphinx.ext.autodoc',
40
+ 'sphinx.ext.intersphinx',
41
+ ]
42
+
43
+ # Looks for pyramid's objects
44
+ intersphinx_mapping = {
45
+ 'pyramid':
46
+ ('http://docs.pylonsproject.org/projects/pyramid/dev/', None)}
47
+
48
+ # Add any paths that contain templates here, relative to this directory.
49
+ templates_path = ['.templates']
50
+
51
+ # The suffix of source filenames.
52
+ source_suffix = '.rst'
53
+
54
+ # The master toctree document.
55
+ master_doc = 'index'
56
+
57
+ # General substitutions.
58
+ project = 'pyramid_exclog'
59
+ copyright = '2011, Agendaless Consulting <chrism@plope.com>'
60
+
61
+ # The default replacements for |version| and |release|, also used in various
62
+ # other places throughout the built documents.
63
+ #
64
+ # The short X.Y version.
65
+ version = '0.1'
66
+ # The full version, including alpha/beta/rc tags.
67
+ release = version
68
+
69
+ # There are two options for replacing |today|: either, you set today to
70
+ # some non-false value, then it is used:
71
+ #today = ''
72
+ # Else, today_fmt is used as the format for a strftime call.
73
+ today_fmt = '%B %d, %Y'
74
+
75
+ # List of documents that shouldn't be included in the build.
76
+ #unused_docs = []
77
+
78
+ # List of directories, relative to source directories, that shouldn't be
79
+ # searched for source files.
80
+ #exclude_dirs = []
81
+
82
+ # The reST default role (used for this markup: `text`) to use for all
83
+ # documents.
84
+ #default_role = None
85
+
86
+ # If true, '()' will be appended to :func: etc. cross-reference text.
87
+ #add_function_parentheses = True
88
+
89
+ # If true, the current module name will be prepended to all description
90
+ # unit titles (such as .. function::).
91
+ #add_module_names = True
92
+
93
+ # If true, sectionauthor and moduleauthor directives will be shown in the
94
+ # output. They are ignored by default.
95
+ #show_authors = False
96
+
97
+ # The name of the Pygments (syntax highlighting) style to use.
98
+ pygments_style = 'sphinx'
99
+
100
+
101
+ # Options for HTML output
102
+ # -----------------------
103
+
104
+ # Add and use Pylons theme
105
+ sys.path.append(os.path.abspath('_themes'))
106
+ html_theme_path = ['_themes']
107
+ html_theme = 'pyramid'
108
+ html_theme_options = dict(github_url='http://github.com/Pylons/pyramid_exclog')
109
+
110
+ # The style sheet to use for HTML and HTML Help pages. A file of that name
111
+ # must exist either in Sphinx' static/ path, or in one of the custom paths
112
+ # given in html_static_path.
113
+ # html_style = 'repoze.css'
114
+
115
+ # The name for this set of Sphinx documents. If None, it defaults to
116
+ # "<project> v<release> documentation".
117
+ #html_title = None
118
+
119
+ # A shorter title for the navigation bar. Default is the same as
120
+ # html_title.
121
+ #html_short_title = None
122
+
123
+ # The name of an image file (within the static path) to place at the top of
124
+ # the sidebar.
125
+ # html_logo = '.static/logo_hi.gif'
126
+
127
+ # The name of an image file (within the static path) to use as favicon of
128
+ # the docs. This file should be a Windows icon file (.ico) being 16x16 or
129
+ # 32x32 pixels large.
130
+ #html_favicon = None
131
+
132
+ # Add any paths that contain custom static files (such as style sheets)
133
+ # here, relative to this directory. They are copied after the builtin
134
+ # static files, so a file named "default.css" will overwrite the builtin
135
+ # "default.css".
136
+ #html_static_path = ['.static']
137
+
138
+ # If not '', a 'Last updated on:' timestamp is inserted at every page
139
+ # bottom, using the given strftime format.
140
+ html_last_updated_fmt = '%b %d, %Y'
141
+
142
+ # If true, SmartyPants will be used to convert quotes and dashes to
143
+ # typographically correct entities.
144
+ #html_use_smartypants = True
145
+
146
+ # Custom sidebar templates, maps document names to template names.
147
+ #html_sidebars = {}
148
+
149
+ # Additional templates that should be rendered to pages, maps page names to
150
+ # template names.
151
+ #html_additional_pages = {}
152
+
153
+ # If false, no module index is generated.
154
+ #html_use_modindex = True
155
+
156
+ # If false, no index is generated.
157
+ #html_use_index = True
158
+
159
+ # If true, the index is split into individual pages for each letter.
160
+ #html_split_index = False
161
+
162
+ # If true, the reST sources are included in the HTML build as
163
+ # _sources/<name>.
164
+ #html_copy_source = True
165
+
166
+ # If true, an OpenSearch description file will be output, and all pages
167
+ # will contain a <link> tag referring to it. The value of this option must
168
+ # be the base URL from which the finished HTML is served.
169
+ #html_use_opensearch = ''
170
+
171
+ # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
172
+ #html_file_suffix = ''
173
+
174
+ # Output file base name for HTML help builder.
175
+ htmlhelp_basename = 'atemplatedoc'
176
+
177
+
178
+ # Options for LaTeX output
179
+ # ------------------------
180
+
181
+ # The paper size ('letter' or 'a4').
182
+ #latex_paper_size = 'letter'
183
+
184
+ # The font size ('10pt', '11pt' or '12pt').
185
+ #latex_font_size = '10pt'
186
+
187
+ # Grouping the document tree into LaTeX files. List of tuples
188
+ # (source start file, target name, title,
189
+ # author, document class [howto/manual]).
190
+ latex_documents = [
191
+ ('index', 'pyramid_exclog.tex', 'pyramid_exclog Documentation',
192
+ 'Repoze Developers', 'manual'),
193
+ ]
194
+
195
+ # The name of an image file (relative to this directory) to place at the
196
+ # top of the title page.
197
+ latex_logo = '.static/logo_hi.gif'
198
+
199
+ # For "manual" documents, if this is true, then toplevel headings are
200
+ # parts, not chapters.
201
+ #latex_use_parts = False
202
+
203
+ # Additional stuff for the LaTeX preamble.
204
+ #latex_preamble = ''
205
+
206
+ # Documents to append as an appendix to all manuals.
207
+ #latex_appendices = []
208
+
209
+ # If false, no module index is generated.
210
+ #latex_use_modindex = True
@@ -0,0 +1,32 @@
1
+ .. _glossary:
2
+
3
+ Glossary
4
+ ========
5
+
6
+ .. glossary::
7
+ :sorted:
8
+
9
+ Pyramid
10
+ A `web framework <http://pylonsproject.org>`_.
11
+
12
+ tween
13
+ A bit of code that sits between the Pyramid router's main request
14
+ handling function and the upstream WSGI component that uses Pyramid as
15
+ its 'app'. The word "tween" is a contraction of "between". A tween may
16
+ be used by Pyramid framework extensions, to provide, for example,
17
+ Pyramid-specific view timing support, bookkeeping code that examines
18
+ exceptions before they are returned to the upstream WSGI application, or
19
+ a variety of other features. Tweens behave a bit like WSGI 'middleware'
20
+ but they have the benefit of running in a context in which they have
21
+ access to the Pyramid application registry as well as the Pyramid
22
+ rendering machinery. See the main Pyramid documentation for more
23
+ information about tweens.
24
+
25
+ Exception view
26
+ An exception view is a :Pyramid view callable which may be invoked when
27
+ an exception is raised during request processing.
28
+
29
+ Logger
30
+ A Python "standard library" ``logging`` module logger. See
31
+ http://docs.python.org/library/logging.html for more information about
32
+ Python standard library logging.
@@ -0,0 +1,175 @@
1
+ pyramid_exclog
2
+ ==============
3
+
4
+ Overview
5
+ --------
6
+
7
+ A package which logs to a Python :term:`logger` when an exception is raised
8
+ by your Pyramid application.
9
+
10
+ .. warning:: This package currently will not work with any released Pyramid;
11
+ it requires the Pyramid trunk (aka "1.2dev").
12
+
13
+ Installation
14
+ ------------
15
+
16
+ Install using setuptools, e.g. (within a virtualenv)::
17
+
18
+ $ easy_install pyramid_exclog
19
+
20
+ Setup
21
+ -----
22
+
23
+ Once ``pyramid_exclog`` is installed, you must use the ``config.include``
24
+ mechanism to include it into your Pyramid project's configuration. In your
25
+ Pyramid project's ``__init__.py``:
26
+
27
+ .. code-block:: python
28
+ :linenos:
29
+
30
+ config = Configurator(.....)
31
+ config.include('pyramid_exclog')
32
+
33
+ Alternately you can use the ``pyramid.includes`` configuration value in your
34
+ ``.ini`` file:
35
+
36
+ .. code-block:: ini
37
+ :linenos:
38
+
39
+ [app:myapp]
40
+ pyramid.includes = pyramid_exclog
41
+
42
+ Using
43
+ -----
44
+
45
+ When this utility is configured into a Pyramid application, whenever a
46
+ request to your application causes an exception to be raised, it will log the
47
+ exception to a Python :term:`logger`.
48
+
49
+ By default, the exception logging machinery will log all exceptions (even
50
+ those eventually caught by a Pyramid :term:`exception view`) except "http
51
+ exceptions" (any exception that derives from the base class
52
+ ``pyramid.httpexceptions.WSGIHTTPException`` such as ``HTTPFound``). You can
53
+ instruct ``pyramid_exclog`` to ignore custom exception types by using the
54
+ ``excview.ignore`` configuration setting, described below.
55
+
56
+ The Python logger name which ``pyramid_exclog`` logs to is named
57
+ ``exc_logger``. You can use the logging configuration in your Pyramid
58
+ application's ``.ini`` file to change the ``exc_logger`` logger to be of a
59
+ specific kind, meaning you can log to a file, to syslog, or to email, and
60
+ other locations. For example, the following configuration sends
61
+ ``pyramid_exclog`` exception logging info to a file (in the current
62
+ directory) named ``exceptions.log``:
63
+
64
+ .. code-block:: ini
65
+ :linenos:
66
+
67
+ # Begin logging configuration
68
+
69
+ [loggers]
70
+ keys = root, starter, exc_logger
71
+
72
+ [handlers]
73
+ keys = console, exc_handler
74
+
75
+ [formatters]
76
+ keys = generic, exc_formatter
77
+
78
+ [logger_root]
79
+ level = INFO
80
+ handlers = console
81
+
82
+ [logger_starter]
83
+ level = DEBUG
84
+ handlers =
85
+ qualname = starter
86
+
87
+ [logger_exc_logger]
88
+ level = ERROR
89
+ handlers = exc_handler
90
+ qualname = exc_logger
91
+
92
+ [handler_console]
93
+ class = StreamHandler
94
+ args = (sys.stderr,)
95
+ level = NOTSET
96
+ formatter = generic
97
+
98
+ [handler_exc_handler]
99
+ class = FileHandler
100
+ args = ('exception.log',)
101
+ level = ERROR
102
+ formatter = exc_formatter
103
+
104
+ [formatter_generic]
105
+ format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
106
+
107
+ [formatter_exc_formatter]
108
+ format = %(asctime)s %(message)s
109
+
110
+ # End logging configuration
111
+
112
+ Most of the "knobs" you'll need to turn relate to changing the logging
113
+ configuration of your application. For information about the logging file
114
+ configuration format, see
115
+ http://docs.python.org/release/2.5.2/lib/logging-config-fileformat.html .
116
+
117
+ However, :mod:`pyramid_exclog`` also has some its own knobs in the form of
118
+ configuration settings which are meant to be placed in the application
119
+ section of your Pyramid's ``.ini`` file. These are:
120
+
121
+ ``exclog.ignore``
122
+
123
+ A list of dotted Python names representing exception types
124
+ (e.g. ``myapp.MyException``) or builtin exception names (e.g.
125
+ ``NotImplementedError`` or ``KeyError``) that represent exceptions which
126
+ should not ever be logged. This setting defaults to a list containing
127
+ only ``pyramid.httpexceptions.WSGIHTTPException``. This list can be in
128
+ the form of a whitespace-separated string, e.g. ``KeyError ValueError
129
+ myapp.MyException`` or it may consume multiple lines in the ``.ini``
130
+ file.
131
+
132
+ Explicit "Tween" Configuration
133
+ ------------------------------
134
+
135
+ Note that the exception logger is implemented as a Pyramid :term:`tween`, and
136
+ it can be used in the explicit tween chain if its implicit position in the
137
+ tween chain is incorrect (see the output of ``paster ptweens``)::
138
+
139
+ [app:myapp]
140
+ pyramid.tweens = someothertween
141
+ pyramid.tweens.excview_tween_factory
142
+ pyramid_exclog.exclog_tween_factory
143
+
144
+ It usually belongs directly above the "MAIN" entry in the ``paster ptweens``
145
+ output, and will attempt to sort there by default as the result of having
146
+ ``include('pyramid_exclog')`` invoked.
147
+
148
+ Putting it above the ``pyramid.tweens.excview_tween_factory`` will cause it
149
+ to log only exceptions that are not caught by an exception view.
150
+
151
+ More Information
152
+ ----------------
153
+
154
+ .. toctree::
155
+ :maxdepth: 1
156
+
157
+ api.rst
158
+ glossary.rst
159
+
160
+
161
+ Reporting Bugs / Development Versions
162
+ -------------------------------------
163
+
164
+ Visit http://github.com/Pylons/pyramid_exclog to download development or
165
+ tagged versions.
166
+
167
+ Visit http://github.com/Pylons/pyramid_exclog/issues to report bugs.
168
+
169
+ Indices and tables
170
+ ------------------
171
+
172
+ * :ref:`glossary`
173
+ * :ref:`genindex`
174
+ * :ref:`modindex`
175
+ * :ref:`search`
@@ -0,0 +1,58 @@
1
+ import logging
2
+
3
+ from pyramid.tweens import EXCVIEW
4
+ from pyramid.settings import aslist
5
+ from pyramid.util import DottedNameResolver
6
+ from pyramid.httpexceptions import WSGIHTTPException
7
+
8
+ resolver = DottedNameResolver(None)
9
+
10
+ import __builtin__
11
+
12
+ def as_globals_list(value):
13
+ L = []
14
+ value = aslist(value)
15
+ for dottedname in value:
16
+ if dottedname in __builtin__.__dict__:
17
+ dottedname = '__builtin__.%s' % dottedname
18
+ obj = resolver.resolve(dottedname)
19
+ L.append(obj)
20
+ return L
21
+
22
+ def exclog_tween_factory(handler, registry):
23
+
24
+ get = registry.settings.get
25
+
26
+ ignored = get('exclog.ignore', (WSGIHTTPException,))
27
+
28
+ def exclog_tween(request, getLogger=logging.getLogger):
29
+ # getLogger injected for testing purposes
30
+ try:
31
+ return handler(request)
32
+ except ignored:
33
+ raise
34
+ except:
35
+ logger = getLogger('exc_logger')
36
+ logger.exception(request.url)
37
+ raise
38
+
39
+ return exclog_tween
40
+
41
+ def includeme(config):
42
+ """
43
+ Set up am implicit :term:`tween` to log exception information that is
44
+ generated by your Pyramid application. The logging data will be sent to
45
+ the Python logger named ``exc_logger``.
46
+
47
+ This tween configured to be placed 'below' the exception view tween. It
48
+ will log all exceptions (even those eventually caught by a Pyramid
49
+ exception view) except 'http exceptions' (any exception that derives from
50
+ ``pyramid.httpexceptions.WSGIHTTPException`` such as ``HTTPFound``). You
51
+ can instruct ``pyramid_exclog`` to ignore custom exception types by using
52
+ the ``excview.ignore`` configuration setting.
53
+ """
54
+ get = config.registry.settings.get
55
+ ignored = as_globals_list(get('exclog.ignore',
56
+ 'pyramid.httpexceptions.WSGIHTTPException'))
57
+ config.registry.settings['exclog.ignore'] = tuple(ignored)
58
+ config.add_tween(exclog_tween_factory, alias='exclog', under=EXCVIEW)
@@ -0,0 +1,118 @@
1
+ import unittest
2
+ from pyramid import testing
3
+
4
+ class Test_exclog_tween_factory(unittest.TestCase):
5
+ def setUp(self):
6
+ self.config = testing.setUp()
7
+ self.registry = self.config.registry
8
+
9
+ def _callFUT(self):
10
+ from pyramid_exclog import exclog_tween_factory
11
+ return exclog_tween_factory(None, self.registry)
12
+
13
+ def test_no_recipients(self):
14
+ handler = self._callFUT()
15
+ self.assertEqual(handler.__name__, 'exclog_tween')
16
+
17
+
18
+ class Test_exclog_tween(unittest.TestCase):
19
+ def setUp(self):
20
+ from pyramid.request import Request
21
+ request = Request.blank('/')
22
+ self.request = request
23
+ self.config = testing.setUp(request=request)
24
+ self.registry = self.config.registry
25
+ self.registry.settings = {}
26
+ request.registry = self.registry
27
+ self.logger = DummyLogger()
28
+
29
+ def getLogger(self, name):
30
+ self.logger.name = name
31
+ return self.logger
32
+
33
+ def handler(self, request):
34
+ raise NotImplementedError
35
+
36
+ def _callFUT(self, handler=None, registry=None, request=None,
37
+ getLogger=None):
38
+ from pyramid_exclog import exclog_tween_factory
39
+ if handler is None:
40
+ handler = self.handler
41
+ if registry is None:
42
+ registry = self.registry
43
+ if request is None:
44
+ request = self.request
45
+ if getLogger is None:
46
+ getLogger = self.getLogger
47
+ tween = exclog_tween_factory(handler, registry)
48
+ return tween(request, getLogger=getLogger)
49
+
50
+ def test_ignored(self):
51
+ self.registry.settings['exclog.ignore'] = (NotImplementedError,)
52
+ self.assertRaises(NotImplementedError, self._callFUT)
53
+ self.assertEqual(len(self.logger.exceptions), 0)
54
+
55
+ def test_notignored(self):
56
+ self.assertRaises(NotImplementedError, self._callFUT)
57
+ self.assertEqual(len(self.logger.exceptions), 1)
58
+ msg = self.logger.exceptions[0]
59
+ self.assertEqual(msg, self.request.url)
60
+
61
+ class Test_includeme(unittest.TestCase):
62
+ def _callFUT(self, config):
63
+ from pyramid_exclog import includeme
64
+ return includeme(config)
65
+
66
+ def test_it(self):
67
+ from pyramid.httpexceptions import WSGIHTTPException
68
+ from pyramid_exclog import exclog_tween_factory
69
+ from pyramid.tweens import EXCVIEW
70
+ config = DummyConfig()
71
+ self._callFUT(config)
72
+ self.assertEqual(config.tweens,
73
+ [(exclog_tween_factory, 'exclog', EXCVIEW, None)])
74
+ self.assertEqual(config.registry.settings['exclog.ignore'],
75
+ (WSGIHTTPException,))
76
+
77
+ def test_it_catchall(self):
78
+ from pyramid_exclog import exclog_tween_factory
79
+ from pyramid.tweens import EXCVIEW
80
+ config = DummyConfig()
81
+ config.settings['exclog.catchall'] = 'true'
82
+ self._callFUT(config)
83
+ self.assertEqual(config.tweens,
84
+ [(exclog_tween_factory, 'exclog', EXCVIEW, None)])
85
+
86
+ def test_it_withignored_builtin(self):
87
+ config = DummyConfig()
88
+ config.settings['exclog.ignore'] = 'NotImplementedError'
89
+ self._callFUT(config)
90
+ self.assertEqual(config.registry.settings['exclog.ignore'],
91
+ (NotImplementedError,))
92
+
93
+ def test_it_withignored_nonbuiltin(self):
94
+ config = DummyConfig()
95
+ config.settings['exclog.ignore'] ='pyramid_exclog.tests.DummyException'
96
+ self._callFUT(config)
97
+ self.assertEqual(config.registry.settings['exclog.ignore'],
98
+ (DummyException,))
99
+
100
+ class DummyException(object):
101
+ pass
102
+
103
+ class DummyLogger(object):
104
+ def __init__(self):
105
+ self.exceptions = []
106
+
107
+ def exception(self, msg):
108
+ self.exceptions.append(msg)
109
+
110
+ class DummyConfig(object):
111
+ def __init__(self):
112
+ self.tweens = []
113
+ self.registry = self
114
+ self.settings = {}
115
+
116
+ def add_tween(self, factory, alias=None, under=None, over=None):
117
+ self.tweens.append((factory, alias, under, over))
118
+
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 1.0
2
+ Name: pyramid-exclog
3
+ Version: 0.1
4
+ Summary: A package which logs to a Python logger when an exception is raised by a Pyramid application
5
+ Home-page: http://docs.pylonsproject.org
6
+ Author: Chris McDonough
7
+ Author-email: pylons-devel@googlegroups.com
8
+ License: BSD-derived (http://www.repoze.org/LICENSE.txt)
9
+ Description: ``pyramid_exclog``
10
+ ===================
11
+
12
+ A package which logs exception information when an error occurs in your
13
+ Pyramid application. See the documentation at
14
+ https://docs.pylonsproject.org/projects/pyramid_exclog/dev/ for more
15
+ information.
16
+
17
+ This package currently will not work with any released Pyramid; it requires
18
+ the Pyramid trunk (aka "1.2dev"), available from
19
+ https://github.com/Pylons/pyramid .
20
+
21
+
22
+ 0.1
23
+ ---
24
+
25
+ - Initial release.
26
+
27
+ Keywords: wsgi pylons pyramid mail tween exception handler
28
+ Platform: UNKNOWN
29
+ Classifier: Intended Audience :: Developers
30
+ Classifier: Programming Language :: Python
31
+ Classifier: Framework :: Pylons
32
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
33
+ Classifier: License :: Repoze Public License
@@ -0,0 +1,23 @@
1
+ .gitignore
2
+ CHANGES.txt
3
+ CONTRIBUTORS.txt
4
+ COPYRIGHT.txt
5
+ LICENSE.txt
6
+ README.rst
7
+ setup.cfg
8
+ setup.py
9
+ tox.ini
10
+ docs/.gitignore
11
+ docs/Makefile
12
+ docs/api.rst
13
+ docs/conf.py
14
+ docs/glossary.rst
15
+ docs/index.rst
16
+ pyramid_exclog/__init__.py
17
+ pyramid_exclog/tests.py
18
+ pyramid_exclog.egg-info/PKG-INFO
19
+ pyramid_exclog.egg-info/SOURCES.txt
20
+ pyramid_exclog.egg-info/dependency_links.txt
21
+ pyramid_exclog.egg-info/not-zip-safe
22
+ pyramid_exclog.egg-info/requires.txt
23
+ pyramid_exclog.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pyramid>=1.2dev
@@ -0,0 +1 @@
1
+ pyramid_exclog
@@ -0,0 +1,15 @@
1
+ [easy_install]
2
+ zip_ok = false
3
+
4
+ [nosetests]
5
+ cover-package = pyramid_exclog
6
+ nocapture = 1
7
+ cover-erase = 1
8
+ where = pyramid_exclog
9
+ match = ^test
10
+
11
+ [egg_info]
12
+ tag_build =
13
+ tag_date = 0
14
+ tag_svn_revision = 0
15
+
@@ -0,0 +1,54 @@
1
+ ##############################################################################
2
+ #
3
+ # Copyright (c) 2008-2011 Agendaless Consulting and Contributors.
4
+ # All Rights Reserved.
5
+ #
6
+ # This software is subject to the provisions of the BSD-like license at
7
+ # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany
8
+ # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL
9
+ # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO,
10
+ # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND
11
+ # FITNESS FOR A PARTICULAR PURPOSE
12
+ #
13
+ ##############################################################################
14
+
15
+ import os
16
+
17
+ from setuptools import setup, find_packages
18
+
19
+ here = os.path.abspath(os.path.dirname(__file__))
20
+ try:
21
+ README = open(os.path.join(here, 'README.rst')).read()
22
+ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
23
+ except IOError:
24
+ README = CHANGES = ''
25
+
26
+ install_requires = [
27
+ 'pyramid>=1.2dev',
28
+ ]
29
+
30
+ setup(name='pyramid_exclog',
31
+ version='0.1',
32
+ description=('A package which logs to a Python logger when an '
33
+ 'exception is raised by a Pyramid application'),
34
+ long_description=README + '\n\n' + CHANGES,
35
+ classifiers=[
36
+ "Intended Audience :: Developers",
37
+ "Programming Language :: Python",
38
+ "Framework :: Pylons",
39
+ "Topic :: Internet :: WWW/HTTP :: WSGI",
40
+ "License :: Repoze Public License",
41
+ ],
42
+ keywords='wsgi pylons pyramid mail tween exception handler',
43
+ author="Chris McDonough",
44
+ author_email="pylons-devel@googlegroups.com",
45
+ url="http://docs.pylonsproject.org",
46
+ license="BSD-derived (http://www.repoze.org/LICENSE.txt)",
47
+ packages=find_packages(),
48
+ include_package_data=True,
49
+ zip_safe=False,
50
+ install_requires=install_requires,
51
+ tests_require=install_requires,
52
+ test_suite="pyramid_exclog",
53
+ entry_points='',
54
+ )
@@ -0,0 +1,30 @@
1
+ [tox]
2
+ envlist =
3
+ py25,py26,py27,pypy,cover
4
+
5
+ [testenv]
6
+ deps = http://static.repoze.org/pyramid_trunk/pyramid-1.2dev.tar.gz # temporary
7
+ commands =
8
+ python setup.py test -q
9
+
10
+ [testenv:jython]
11
+ commands =
12
+ jython setup.py test -q
13
+
14
+ [testenv:cover]
15
+ basepython =
16
+ python2.6
17
+ commands =
18
+ python setup.py nosetests --with-xunit --with-xcoverage
19
+ deps =
20
+ nose
21
+ coverage==3.4
22
+ nosexcover
23
+ http://static.repoze.org/pyramid_trunk/pyramid-1.2dev.tar.gz # temporary
24
+
25
+
26
+ # we separate coverage into its own testenv because a) "last run wins" wrt
27
+ # cobertura jenkins reporting and b) pypy and jython can't handle any
28
+ # combination of versions of coverage and nosexcover that i can find.
29
+ # coverage==3.4 is required by nosexcover.
30
+