Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #14 from snok/version
Browse files Browse the repository at this point in the history
Version bump
  • Loading branch information
Sondre Lillebø Gundersen authored Jun 29, 2020
2 parents f17c689 + 906edef commit 07f1139
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# getting the report --> `coverage report`

[run]
include = js_logger/*
include = django_js_logger/*

[report]
exclude_lines =
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# poetry install
# - name: Test with pytest
# run: |
# poetry run pytest --cov=js_logger --verbose --color=yes --assert=plain --cov-report=xml
# poetry run pytest --cov=django_js_logger --verbose --color=yes --assert=plain --cov-report=xml
# poetry run coverage report
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
# poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# poetry run pytest --cov=js_logger --verbose --color=yes --assert=plain
# poetry run pytest --cov=django_js_logger --verbose --color=yes --assert=plain
# poetry run coverage report
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
recursive-include js_logger/static *
recursive-include django_js_logger/static *
include AUTHORS
include LICENSE
include README.rst
64 changes: 33 additions & 31 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
========================
Django Javascript Logger
========================

.. image:: https://img.shields.io/pypi/v/django-js-logger.svg
:target: https://pypi.org/project/django-js-logger/

.. image:: https://img.shields.io/pypi/pyversions/django-js-logger.svg
:target: https://pypi.org/project/django-js-logger/

.. image:: https://img.shields.io/pypi/djversions/django-js-logger.svg
:target: https://pypi.python.org/pypi/django-js-logger

.. image:: https://codecov.io/gh/sondrelg/django-js-logger/branch/master/graph/badge.svg
:alt: Code coverage
:target: https://codecov.io/gh/sondrelg/django-js-logger/

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:alt: Code style black
:target: https://pypi.org/project/django-swagger-tester/

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:alt: Pre-commit enabled
:target: https://github.com/pre-commit/pre-commit
.. raw:: html

.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
:alt: Checked with mypy
:target: http://mypy-lang.org/
<h1 align="center">Django Javascript Logger ✏</h1>

<p align="center">
<a href="https://pypi.org/project/django-js-logger/">
<img src="https://img.shields.io/pypi/v/django-js-logger.svg" alt="Package version">
</a>
<a href="https://pypi.org/project/django-js-logger/">
<img src="https://img.shields.io/pypi/pyversions/django-js-logger.svg" alt="Compatible python version">
</a>
<a href="https://pypi.python.org/pypi/django-js-logger">
<img src="https://img.shields.io/pypi/djversions/django-js-logger.svg" alt="Compatible django versions">
</a>
<a href="https://codecov.io/gh/sondrelg/django-js-logger/">
<img src="https://codecov.io/gh/sondrelg/django-js-logger/branch/master/graph/badge.svg" alt="Code coverage">
</a>
<br>
<a href="https://github.com/pre-commit/pre-commit">
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white" alt="Pre-commit enabled">
</a>
<a href="https://pypi.org/project/django-swagger-tester/">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style black">
</a>
<a href="http://mypy-lang.org/">
<img src="http://www.mypy-lang.org/static/mypy_badge.svg" alt="Checked with mypy">
</a>

<br>

</p>

|

This is a very simple Django app for forwarding console logs and console errors to dedicated Django loggers.

Expand Down Expand Up @@ -59,16 +61,16 @@ Installing with poetry::
Quick start
-----------

1. Add ``js_logger`` to your INSTALLED_APPS settings::
1. Add ``django_js_logger`` to your INSTALLED_APPS settings::

INSTALLED_APPS = [
...
'js_logger',
'django_js_logger',
]

2. Include the packages URLconf in your project urls.py like this::

path('js-logs/', include('js_logger.urls')),
path('js-logs/', include('django_js_logger.urls')),

3. Optionally, specify your logging preferences by adding ``JS_LOGGER`` to your settings::

Expand Down
2 changes: 1 addition & 1 deletion demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'js_logger',
'django_js_logger',
]

MIDDLEWARE = [
Expand Down
2 changes: 1 addition & 1 deletion demo/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase

from js_logger.config import get_logger, Settings
from django_js_logger.config import get_logger, Settings
from selenium.webdriver import Chrome


Expand Down
2 changes: 1 addition & 1 deletion demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

urlpatterns = [
path('', views.index),
path('js-logs/', include('js_logger.urls')),
path('js-logs/', include('django_js_logger.urls')),
]
2 changes: 1 addition & 1 deletion js_logger/__init__.py → django_js_logger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.1.0'
__author__ = 'Sondre Lillebø Gundersen'

default_app_config = 'js_logger.apps.JsConfig'
default_app_config = 'django_js_logger.apps.JsConfig'
2 changes: 1 addition & 1 deletion js_logger/apps.py → django_js_logger/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class JsConfig(AppConfig):
name = 'js_logger'
name = 'django_js_logger'
File renamed without changes.
2 changes: 1 addition & 1 deletion js_logger/urls.py → django_js_logger/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path

from js_logger.views import JsLoggerApi
from django_js_logger.views import JsLoggerApi

urlpatterns = [
path('', JsLoggerApi.as_view(), name='django_js_logger-api'),
Expand Down
2 changes: 1 addition & 1 deletion js_logger/views.py → django_js_logger/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework.status import HTTP_204_NO_CONTENT
from rest_framework.views import APIView

from js_logger.config import settings
from django_js_logger.config import settings

loggers = {
'console_log': settings.CONSOLE_LOG_LOGGER,
Expand Down
80 changes: 80 additions & 0 deletions docs/PYPI_README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
========================
Django Javascript Logger
========================

.. image:: https://img.shields.io/pypi/v/django-js-logger.svg
:target: https://pypi.org/project/django-js-logger/

.. image:: https://img.shields.io/pypi/pyversions/django-js-logger.svg
:target: https://pypi.org/project/django-js-logger/

.. image:: https://img.shields.io/pypi/djversions/django-js-logger.svg
:target: https://pypi.python.org/pypi/django-js-logger

.. image:: https://codecov.io/gh/sondrelg/django-js-logger/branch/master/graph/badge.svg
:alt: Code coverage
:target: https://codecov.io/gh/sondrelg/django-js-logger/

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:alt: Pre-commit enabled
:target: https://github.com/pre-commit/pre-commit

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:alt: Code style black
:target: https://pypi.org/project/django-swagger-tester/

.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
:alt: Checked with mypy
:target: http://mypy-lang.org/

|
This is a very simple Django app for forwarding console logs and console errors to dedicated Django loggers.

Useful for catching Javascript errors that are not logged by Django natively and would otherwise only be logged to the client's console. Can be particularly useful if you have JavaScript running on top of our server-side rendered views.

The app works by posting *all relevant events* to an internal Django API, which logs them to one of two loggers. Not sure what impact this has on an apps performance, but it likely should not run anywhere near performance-sensitive production environments. Primarily this is intended to be a debugging aid.

A flowchart of the app's structure looks something like this:

.. image:: docs/img/flowchart.png

The package is open to contributions.

Installation
------------

Installing with pip::

pip install django-js-logger

Installing with poetry::

poetry add django-js-logger

Quick start
-----------

1. Add ``django_js_logger`` to your INSTALLED_APPS settings::

INSTALLED_APPS = [
...
'django_js_logger',
]

2. Include the packages URLconf in your project urls.py like this::

path('js-logs/', include('django_js_logger.urls')),

3. Optionally, specify your logging preferences by adding ``JS_LOGGER`` to your settings::

JS_LOGGER = {
'CONSOLE_LOG_LEVEL': 'INFO',
'CONSOLE_ERROR_LEVEL': 'WARNING'
}

4. Add the required static file to your project by running ``manage.py collectstatic``. This should add a folder, ``django_js_logger`` with the file ``logger.js``. If this is not the case, you can copy the file manually from the demo project above.

5. Import ``logger.js`` in the views you wish to log from by adding a JS import to your templates::

<script src="static/django_js_logger/logger.js"></script>
Loading

0 comments on commit 07f1139

Please sign in to comment.