diff options
author | 2019-04-07 22:57:28 +0200 | |
---|---|---|
committer | 2019-04-07 22:57:28 +0200 | |
commit | 5d98792d09e78b7f1a3ecdaba458a0c3c74a0faf (patch) | |
tree | a0b8316df691667f72cd719c0cb311bdda160e05 /pydis_site | |
parent | Merge pull request #198 from gdude2002/django+176/project-layout (diff) |
Add the `LogEntry` model.
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/api/migrations/0035_create_table_log_entry.py | 28 | ||||
-rw-r--r-- | pydis_site/apps/api/models.py | 42 |
2 files changed, 70 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0035_create_table_log_entry.py b/pydis_site/apps/api/migrations/0035_create_table_log_entry.py new file mode 100644 index 00000000..30ff1ffd --- /dev/null +++ b/pydis_site/apps/api/migrations/0035_create_table_log_entry.py @@ -0,0 +1,28 @@ +# Generated by Django 2.1.5 on 2019-04-07 20:53 + +from django.db import migrations, models +import django.utils.timezone +import pydis_site.apps.api.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0034_add_botsetting_name_validator'), + ] + + operations = [ + migrations.CreateModel( + name='LogEntry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('application', models.CharField(choices=[('bot', 'Bot'), ('seasonalbot', 'Seasonalbot'), ('site', 'Website')], help_text='The application that generated this log entry.', max_length=20)), + ('logger_name', models.CharField(help_text='The name of the logger that generated this log entry.', max_length=100)), + ('timestamp', models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time when this entry was created.')), + ('level', models.CharField(choices=[('debug', 'Debug'), ('info', 'Info'), ('warning', 'Warning'), ('error', 'Error'), ('critical', 'Critical')], help_text='The logger level at which this entry was emitted. The levels correspond to the Python `logging` levels.', max_length=8)), + ('module', models.CharField(help_text='The fully qualified path of the module generating this log line.', max_length=100)), + ('line', models.PositiveSmallIntegerField(help_text='The line at which the log line was emitted.')), + ], + bases=(pydis_site.apps.api.models.ModelReprMixin, models.Model), + ), + ] diff --git a/pydis_site/apps/api/models.py b/pydis_site/apps/api/models.py index 86c99f86..a541e4ab 100644 --- a/pydis_site/apps/api/models.py +++ b/pydis_site/apps/api/models.py @@ -450,3 +450,45 @@ class Nomination(ModelReprMixin, models.Model): auto_now_add=True, help_text="The creation date of this nomination." ) + +class LogEntry(ModelReprMixin, models.Model): + """A log entry generated by one of the PyDis applications.""" + + application = models.CharField( + max_length=20, + help_text="The application that generated this log entry.", + choices=( + ('bot', 'Bot'), + ('seasonalbot', 'Seasonalbot'), + ('site', 'Website') + ) + ) + logger_name = models.CharField( + max_length=100, + help_text="The name of the logger that generated this log entry." + ) + timestamp = models.DateTimeField( + default=timezone.now, + help_text="The date and time when this entry was created." + ) + level = models.CharField( + max_length=8, # 'critical' + choices=( + ('debug', 'Debug'), + ('info', 'Info'), + ('warning', 'Warning'), + ('error', 'Error'), + ('critical', 'Critical') + ), + help_text=( + "The logger level at which this entry was emitted. The levels " + "correspond to the Python `logging` levels." + ) + ) + module = models.CharField( + max_length=100, + help_text="The fully qualified path of the module generating this log line." + ) + line = models.PositiveSmallIntegerField( + help_text="The line at which the log line was emitted." + ) |