Giter Club home page Giter Club logo

django-logger's Introduction

To be removed!

This app is no longer maintained or developed and is soon to be removed. It was merely a draft, but it turned out, that there are far too many better solutions for this problem.

For statistics we now use django-influxdb-metrics with grafana.

For logging certain events you might want to check out django-object-events.

Django Logger

A Django application for logging events and saving them into your database so that you can run computations and reports on them later.

Installation

You need to install the following prerequisites in order to use this app:

pip install Django

To install the latest commit from GitHub:

$ pip install -e git://github.com/bitmazk/django-logger.git#egg=logger

Add logger to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...,
    'logger',
)

Usage

from logger import Logger

def my_function(args):
    # create a logger instance
    logger = Logger()

    # call the ``create_log`` method
    logger.create_log(
        'action_name', 'parameter_type_name', 'value')

The action argument of logger.create_log() is a string defining the kind of action, that is logged. E.g. 'payment' You can see it as a way of grouping log items.

The parameter_type_name is either a string or a list of strings containing the types of values stored. E.g. ['item count', 'payment amount', 'user']

Finally the value argument is a list of values or a single value that can be either a string, an integer, a date or datetime, a decimal, a bool or a django model instance. E.g. [12, decimal.Decimal('299.99'), request.user]

So the full call of create_log from the example would look like:

logger.create_log(
    'payment',
    ['item count', 'payment amount', 'user'],
    [12, decimal.Decimal('299.99'), request.user],
)

Currently the Log objects stored this way can be reviewed through the django admin.

Contribute

If you want to contribute to this project, please perform the following steps:

# Fork this repository
# Clone your fork
$ mkvirtualenv -p python2.7 django-logger
$ pip install -r requirements.txt
$ ./logger/tests/runtests.sh
# You should get no failing tests

$ git co -b feature_branch master
# Implement your feature and tests
# Describe your change in the CHANGELOG.txt
$ git add . && git commit
$ git push origin feature_branch
# Send us a pull request for your feature branch

Whenever you run the tests a coverage output will be generated in tests/coverage/index.html. When adding new features, please make sure that you keep the coverage at 100%.

Roadmap

Check the issue tracker on github for milestones and features to come.

django-logger's People

Contributors

dkaufhold avatar mbrochh avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

the3hm

django-logger's Issues

Unsafe import

https://github.com/bitmazk/django-logger/blob/master/setup.py#L3 is causing this:

$ pip install --no-deps -e git://github.com/bitmazk/django-logger.git#egg=logger
Obtaining logger from git+git://github.com/bitmazk/django-logger.git#egg=logger
  Cloning git://github.com/bitmazk/django-logger.git to /Users/peterbe/virtualenvs/socorro/src/logger
  Running setup.py (path:/Users/peterbe/virtualenvs/socorro/src/logger/setup.py) egg_info for package logger
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/Users/peterbe/virtualenvs/socorro/src/logger/setup.py", line 3, in <module>
        import logger
      File "logger/__init__.py", line 2, in <module>
        from logger.utils import Logger  # NOQA
      File "logger/utils.py", line 2, in <module>
        from logger.models import (
      File "logger/models.py", line 4, in <module>
        from django.contrib.contenttypes import generic
      File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/contrib/contenttypes/generic.py", line 10, in <module>
        from django.db import connection
      File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/db/__init__.py", line 11, in <module>
        if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
      File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/conf/__init__.py", line 53, in __getattr__
        self._setup(name)
      File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/conf/__init__.py", line 46, in _setup
        % (desc, ENVIRONMENT_VARIABLE))
    django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/Users/peterbe/virtualenvs/socorro/src/logger/setup.py", line 3, in <module>

    import logger

  File "logger/__init__.py", line 2, in <module>

    from logger.utils import Logger  # NOQA

  File "logger/utils.py", line 2, in <module>

    from logger.models import (

  File "logger/models.py", line 4, in <module>

    from django.contrib.contenttypes import generic

  File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/contrib/contenttypes/generic.py", line 10, in <module>

    from django.db import connection

  File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/db/__init__.py", line 11, in <module>

    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:

  File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/conf/__init__.py", line 53, in __getattr__

    self._setup(name)

  File "/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/django/conf/__init__.py", line 46, in _setup

    % (desc, ENVIRONMENT_VARIABLE))

django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/peterbe/virtualenvs/socorro/src/logger
Storing debug log for failure in /Users/peterbe/.pip/pip.log

It can't import the package because it can only be imported when running with an env variable set.

Not on pypi?

$ pip install --no-deps django-logger
Downloading/unpacking django-logger
  Could not find any downloads that satisfy the requirement django-logger
Cleaning up...
No distributions at all found for django-logger
Storing debug log for failure in /Users/peterbe/.pip/pip.log

:(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.