{"id":14483342,"url":"https://github.com/dcramer/django-db-log","last_synced_at":"2025-03-17T16:10:19.700Z","repository":{"id":666959,"uuid":"310119","full_name":"dcramer/django-db-log","owner":"dcramer","description":"This project is no longer updated. Please see https://sentry.io/ for its successor","archived":false,"fork":false,"pushed_at":"2012-10-31T10:05:53.000Z","size":257,"stargazers_count":124,"open_issues_count":8,"forks_count":25,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-15T15:17:39.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sentry.io","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcramer.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-09-17T19:34:43.000Z","updated_at":"2025-02-24T19:27:50.000Z","dependencies_parsed_at":"2022-07-08T05:42:44.204Z","dependency_job_id":null,"html_url":"https://github.com/dcramer/django-db-log","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Fdjango-db-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Fdjango-db-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Fdjango-db-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Fdjango-db-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcramer","download_url":"https://codeload.github.com/dcramer/django-db-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746238,"owners_count":20341204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-03T00:01:42.572Z","updated_at":"2025-03-17T16:10:19.673Z","avatar_url":"https://github.com/dcramer.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"-------------\ndjango-db-log\n-------------\n\nLogs Django exceptions to your database handler.\n\n*This project has been replaced by Sentry (https://getsentry.com)*\n\n=========\nUpgrading\n=========\n\nIf you use South migrations, simply run::\n\n\tpython manage.py migrate djangodblog\n\nIf you don't use South, then start.\n\n###############\nNotable Changes\n###############\n\n* 2.1.0 There is no longer a middleware. Instead, we use a fallback exception handler which catches all.\n* 2.0.0 Added `checksum` column to Error. Several indexes were created. Checksum calculation slightly changed.\n* 1.4.0 Added `logger` column to both Error and ErrorBatch. `traceback` and `class_name` are now nullable.\n* 1.3.0 Added `level` column to both Error and ErrorBatch.\n\n=======\nInstall\n=======\n\nThe easiest way to install the package is via pip::\n\n\tpip install django-db-log --upgrade\n\nOR, if you're not quite on the same page (work on that), with setuptools::\n\n\teasy_install django-db-log\n\nOnce installed, update your settings.py and add dblog to ``INSTALLED_APPS``::\n\n\tINSTALLED_APPS = (\n\t    'django.contrib.admin',\n\t    'django.contrib.auth',\n\t    'django.contrib.contenttypes',\n\t    'django.contrib.sessions',\n\t    'djangodblog',\n\t    ...\n\t)\n\nFinally, run ``python manage.py syncdb`` to create the database tables.\n\n=============\nConfiguration\n=============\n\nSeveral options exist to configure django-db-log via your ``settings.py``:\n\n######################\nDBLOG_CATCH_404_ERRORS\n######################\n\nEnable catching of 404 errors in the logs. Default value is ``False``::\n\n\tDBLOG_CATCH_404_ERRORS = True\n\nYou can skip other custom exception types by adding a ``skip_dblog = True`` attribute to them.\n\n####################\nDBLOG_DATABASE_USING\n####################\n\nUse a secondary database to store error logs. This is useful if you have several websites and want to aggregate error logs onto one database server::\n\n\t# This should correspond to a key in your DATABASES setting\n\tDBLOG_DATABASE_USING = 'default'\n\nYou should also enable the ``DBLogRouter`` to avoid things like extraneous table creation::\n\n\tDATABASE_ROUTERS = [\n\t\t'djangodblog.routers.DBLogRouter',\n\t\t...\n\t]\n\nSome things to note:\n\n* This functionality REQUIRES Django 1.2.\n\n#########################\nDBLOG_ENHANCED_TRACEBACKS\n#########################\n\nEnables showing full embedded (enhanced) tracebacks within the administration for \"Messages\". These work almost identically to the default exception pages within Django's DEBUG environment::\n\n\t# Disable embedded interactive tracebacks in the admin\n\tDBLOG_ENHANCED_TRACEBACKS = False\n\n* Note: Even if you disable displaying of enhanced tracebacks, dblog will still store the entire exception stacktrace.\n\n#############\nDBLOG_LOGGING\n#############\n\nEnabling this setting will turn off automatic database logging within the exception handler, and instead send all exceptions to the named logger ``dblog``. Use this in conjuction with ``djangodblog.handlers.DBLogHandler`` or your own handler to tweak how logging is dealt with.\n\nA good example use case for this, is if you want to write to something like a syslog ahead of time, and later process that into the database with another tool.\n\n############################\nIntegration with ``logging``\n############################\n\ndjango-db-log supports the ability to directly tie into the ``logging`` module. To use it simply add ``DBLogHandler`` to your logger::\n\n\timport logging\n\tfrom djangodblog.handlers import DBLogHandler\n\t\n\tlogging.getLogger().addHandler(DBLogHandler())\n\n\t# Add StreamHandler to dblog's default so you can catch missed exceptions\n\tlogging.getLogger('dblog').addHandler(logging.StreamHandler())\n\nYou can also use the ``exc_info`` and ``extra=dict(url=foo)`` arguments on your ``log`` methods. This will store the appropriate information and allow django-db-log to render it based on that information:\n\n\tlogging.error('There was some crazy error', exc_info=sys.exc_info(), extra={'url': request.build_absolute_uri()})\n\n=====\nUsage\n=====\n\nYou will find two new admin panels in the automatically built Django administration:\n\n* Messages (Error)\n* Message summaries (ErrorBatch)\n\nIt will store every single error inside of the `Errors` model, and it will store a collective, or summary, of errors inside of `Error batches` (this is more useful for most cases). If you are using this on multiple sites with the same database, the `Errors` table also contains the SITE_ID for which it the error appeared on.\n\nIf you wish to access these within your own views and models, you may do so via the standard model API::\n\n\tfrom djangodblog.models import Error, ErrorBatch\n\t\n\t# Pull the last 10 unresolved errors.\n\tErrorBatch.objects.filter(status=0).order_by('-last_seen')[0:10]\n\nYou can also record errors outside of handler if you want::\n\n\tfrom djangodblog.models import Error\n\t\n\ttry:\n\t\t...\n\texcept Exception, exc:\n\t\tError.objects.create_from_exception(exc, [url=None])\n\nIf you wish to log normal messages (useful for non-``logging`` integration)::\n\n\tfrom djangodblog.models import Error\n\timport logging\n\t\n\tError.objects.create_from_text('Error Message'[, level=logging.WARNING, url=None])\n\nBoth the ``url`` and ``level`` parameters are optional. ``level`` should be one of the following:\n\n* ``logging.DEBUG``\n* ``logging.INFO``\n* ``logging.WARNING``\n* ``logging.ERROR``\n* ``logging.FATAL``\n\nIf you have a custom exception class, similar to Http404, or something else you don't want to log,\nyou can also add ``skip_dblog = True`` to your exception class or instance, and dblog will simply ignore\nthe error.\n\n=====\nNotes\n=====\n\n* django-db-log will automatically integrate with django-idmapper.\n* django-db-log supports South migrations.\n* The fact that the admin shows large quantities of results, even if there aren't, is not a bug. This is an efficiency hack on top of Django.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcramer%2Fdjango-db-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcramer%2Fdjango-db-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcramer%2Fdjango-db-log/lists"}