-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from FJNR-inc/develop
New release
- Loading branch information
Showing
27 changed files
with
862 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
'workplace', | ||
'store', | ||
'retirement', | ||
'log_management', | ||
'storages', | ||
'anymail', | ||
'simple_history', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
from django.contrib import admin | ||
|
||
from log_management.models import Log | ||
|
||
|
||
class LogAdmin(admin.ModelAdmin): | ||
list_display = ('source', 'level', 'error_code', 'message',) | ||
search_fields = ( | ||
'message', 'additional_data', 'level', 'source', 'error_code', | ||
'traceback_data') | ||
list_filter = ( | ||
'level', | ||
'source', | ||
'error_code', | ||
) | ||
|
||
|
||
admin.site.register(Log, LogAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class LogManagementConfig(AppConfig): | ||
name = 'log_management' | ||
verbose_name = 'Log' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 2.2.5 on 2019-10-03 10:33 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Log', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('source', models.CharField(max_length=100, verbose_name='Source')), | ||
('level', models.CharField(max_length=100, verbose_name='Level')), | ||
('message', models.TextField(verbose_name='Message')), | ||
('error_code', models.CharField(blank=True, max_length=100, null=True, verbose_name='Error Code')), | ||
('additional_data', models.TextField(blank=True, null=True, verbose_name='Additional data')), | ||
('traceback_data', models.TextField(blank=True, null=True, verbose_name='TraceBack')), | ||
], | ||
options={ | ||
'verbose_name': 'Log', | ||
'verbose_name_plural': 'Logs', | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import json | ||
import traceback | ||
|
||
from django.db import models | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class Log(models.Model): | ||
|
||
LEVEL_ERROR = 'ERROR' | ||
LEVEL_INFO = 'INFO' | ||
LEVEL_DEBUG = 'DEBUG' | ||
|
||
source = models.CharField( | ||
max_length=100, | ||
verbose_name=_("Source"), | ||
) | ||
|
||
level = models.CharField( | ||
max_length=100, | ||
verbose_name=_("Level"), | ||
) | ||
|
||
message = models.TextField( | ||
verbose_name=_("Message"), | ||
) | ||
|
||
error_code = models.CharField( | ||
blank=True, | ||
null=True, | ||
max_length=100, | ||
verbose_name=_("Error Code"), | ||
) | ||
|
||
additional_data = models.TextField( | ||
blank=True, | ||
null=True, | ||
verbose_name=_("Additional data"), | ||
) | ||
|
||
traceback_data = models.TextField( | ||
blank=True, | ||
null=True, | ||
verbose_name=_("TraceBack"), | ||
) | ||
|
||
class Meta: | ||
verbose_name = _("Log") | ||
verbose_name_plural = _("Logs") | ||
|
||
@classmethod | ||
def error(cls, source, message, error_code=None, additional_data=None): | ||
traceback_data = ''.join(traceback.format_stack(limit=10)) | ||
new_log = Log( | ||
level=cls.LEVEL_ERROR, | ||
source=source, | ||
message=message, | ||
traceback_data=traceback_data | ||
) | ||
|
||
if error_code: | ||
new_log.error_code = error_code | ||
if additional_data: | ||
new_log.additional_data = additional_data | ||
|
||
new_log.save() | ||
|
||
return new_log |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
|
||
from django.test import TestCase | ||
|
||
from log_management.models import Log | ||
|
||
|
||
class LogsTests(TestCase): | ||
def test_create_error(self): | ||
additional_data = { | ||
'title': "Place exclusive pour 24h", | ||
'default_from': 'from@email', | ||
'user_email': 'user.email', | ||
'merge_data': 'merge_data', | ||
'template': 'reserved_place' | ||
} | ||
new_log = Log.error( | ||
source='SENDING_BLUE_TEMPLATE', | ||
message='err', | ||
additional_data=json.dumps(additional_data) | ||
) | ||
|
||
self.assertEqual(new_log.source, 'SENDING_BLUE_TEMPLATE') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ pycodestyle==2.5.0 | |
coveralls==1.8.2 | ||
responses==0.10.6 | ||
six==1.12.0 | ||
awscli==1.16.240 | ||
awscli==1.16.252 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 2.2.5 on 2019-10-02 02:57 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('retirement', '0018_auto_20190906_1322'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='historicalretreat', | ||
name='carpool_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Carpool URL'), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalretreat', | ||
name='form_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Form URL'), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalretreat', | ||
name='review_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Review URL'), | ||
), | ||
migrations.AlterField( | ||
model_name='retreat', | ||
name='carpool_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Carpool URL'), | ||
), | ||
migrations.AlterField( | ||
model_name='retreat', | ||
name='form_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Form URL'), | ||
), | ||
migrations.AlterField( | ||
model_name='retreat', | ||
name='review_url', | ||
field=models.TextField(blank=True, null=True, verbose_name='Review URL'), | ||
), | ||
] |
Oops, something went wrong.