djangosnippets.org: Latest snippets tagged with 'log'http://djangosnippets.org/tags/log/2021-03-18T19:34:06.513820-05:00django database snippet
2021-03-18T19:34:06.513820-05:00ItsRLuohttp://djangosnippets.org/snippets/10820/<p>..</p>
Freely redistributableShow Logs on Django Admin
2017-09-12T06:50:45.514890-05:00ekinertachttp://djangosnippets.org/snippets/10621/<p>Place the code any admin.py file in your registered apps</p>
Freely redistributablePassword Obfuscation Log Filter
2013-06-28T17:08:04.046722-05:00nikmolnarhttp://djangosnippets.org/snippets/2966/<p>This is a simple logging <a href="https://docs.djangoproject.com/en/1.5/topics/logging/#topic-logging-parts-filters">filter</a> to ensure that user-entered passwords aren't recorded in the log or emailed to admins as part of the request data if an error occurs during registration/login.</p>
Freely redistributableSQL Log Middleware - with multiple databases
2011-02-03T08:25:59.699164-06:00guglielmocelatahttp://djangosnippets.org/snippets/2347/<p>This is an improvement of <a href="http://djangosnippets.org/users/joshua/">joshua</a>'s <a href="http://djangosnippets.org/snippets/61/">SQL Log Middleware</a>. </p>
<p>If you have more than one database connection, then all queries are logged, grouped by connection.</p>
<p>If a connection has no queries, then it's not shown.</p>
Freely redistributableLog all interaction with user to the DB
2011-01-17T15:09:15.275328-06:00inuwashihttp://djangosnippets.org/snippets/2325/<p>Due to compliance requirements in the financials industry we needed to log every request a user made to our system, the action taken (view function) and response from the server.
</p>
<p>I found a lot of other logging solution bit most revolved around debugging and DB query logging. I needed to …</p>
Freely redistributableLog username in Apache access logs
2010-03-02T03:48:16.645932-06:00arthurhttp://djangosnippets.org/snippets/1947/<p>This is a piece of middleware that reports the logged-in user back to Apache. This should cause the logged-in user to be present in the apache access log.</p>
<p>Put it in <code>settings.MIDDLEWARE_CLASSES</code> after <code>AuthenticationMiddleware</code>.</p>
<p>This has been tested with mod_python but does <a href="http://groups.google.com/group/modwsgi/browse_thread/thread/8785a99d4ba7ee99">not work with wsgi</a>.</p>
Freely redistributableSQL Log To Console Middleware
2009-08-06T16:21:53.683787-05:00davepeckhttp://djangosnippets.org/snippets/1672/<p>When running the Django development server, this middleware causes all executed SQL queries to get printed out to the console.</p>
<p>This is based on <a href="http://www.djangosnippets.org/snippets/161/">Snippet 161</a>. The big difference is that 161 logs by adding stuff to your response text, which isn't very convenient IMO.</p>
Freely redistributableExtended logging module
2009-07-09T05:38:57.801227-05:00onlineherohttp://djangosnippets.org/snippets/1619/<p>The django_admin_log only logs changes, not simple requests.</p>
<p>Sometimes it can be useful to log when a user of your admin interface is checking out important data, for instance if you are making a system with personal sensitive data, that needs to comply with government / company policies.</p>
<p>This will …</p>
Freely redistributableWho's helping a lot in IRC
2008-04-19T06:10:05.297581-05:00akaiholahttp://djangosnippets.org/snippets/710/<p>We had some fun today on the #django IRC channel searching and counting through past logs for people saying "thanks" to <a href="http://djangopeople.net/magus/">a known very helpful person</a>.</p>
<p>Here's a unix shell script for checking your own score if you're using Pidgin and have logging turned on.</p>
<p>Replace ".purple" with ".gaim" …</p>
Freely redistributableLog errors to a file
2008-03-10T16:08:35.561047-05:00kcarnoldhttp://djangosnippets.org/snippets/639/<p>This is another example use of the <a href="http://www.djangosnippets.org/snippets/638/">exception middleware</a>. It shows how to log exceptions to a file. Someone wanted to do this to avoid DOS-ing the email server in case of a silly error.</p>
<p>(untested.)</p>
Freely redistributableColor SQL logging middleware
2008-01-30T13:26:32.604444-06:00moehttp://djangosnippets.org/snippets/571/<p>Yet another SQL logger, this time with color and tresholds.
By default it will only print a summary line (total time, query count) unless one of the tresholds (total time, query count, individual query time) was exceeded. </p>
<p>You may use LOG_COLORSQL_VERBOSE = True to get the raw SQL for all …</p>
Freely redistributableLogging solution for mod_python/FCGI
2007-09-18T14:11:29.683282-05:00mikeivanovhttp://djangosnippets.org/snippets/421/<p>The solution is based on <a href="http://www.djangosnippets.org/snippets/420/">dballanc's snippet</a>.</p>
<p>Can easily be combined with any of the <a href="http://www.djangosnippets.org/tags/debug/">SQL tracing solutions</a>.</p>
<p>You might want to run a separate logging server and redirect your logs there. Please refer to the <a href="http://docs.python.org/lib/module-logging.html">logging reference manual</a>.</p>
Freely redistributableSQL Log Middleware + duplicates
2007-07-27T03:51:35.148635-05:00guettlihttp://djangosnippets.org/snippets/344/<p>This is based on <a href="/snippets/161/">Snippet 161</a>
It marks duplicated SQL queries.</p>
<p>To avoid duplicates read:</p>
<p><a href="http://www.djangoproject.com/documentation/db-api/#caching-and-querysets">Caching and Queryset</a></p>
<p>Sept. 07: Updated for current trunk: 'response' behaves like 'response.header'
22. October '07: Log into directory.</p>
Freely redistributableMaxMind(R) GeoIP Lite CSV Import
2007-07-18T20:55:43.363148-05:00jbronnhttp://djangosnippets.org/snippets/328/<p>Use this script to import the Maxmind GeoIP lite CSV datasets into your database. This takes at least 200MB of RAM; the resulting database will be ~400MB. Stick in the same directory as the <a href="http://www.djangosnippets.org/snippets/327/">models</a>. Make sure to set <code>DEBUG=False</code> to prevent running out of memory during import.</p>
Freely redistributableMaxMind(R) GeoIP Lite geolocation models
2007-07-18T20:49:11.932111-05:00jbronnhttp://djangosnippets.org/snippets/327/<p>This provides GeoDjango models for the maxmind GeoIP Lite data products. Use the corresponding <a href="http://www.djangosnippets.org/snippets/328/">CSV import script</a> for data import. Requires: <a href="http://code.djangoproject.com/wiki/GeoDjango">GeoDjango</a> and the <a href="http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch">BigIntegerField patch</a> by Peter Nixon. </p>
Freely redistributable