Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-russell committed Mar 12, 2024
1 parent ec9ba33 commit e5af022
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions fractal_database_matrix/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 5.0.2 on 2024-03-07 22:55
# Generated by Django 5.0.3 on 2024-03-12 21:29

import django.db.models.deletion
import uuid
from django.db import migrations, models


Expand All @@ -16,7 +17,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='MatrixCredentials',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('deleted', models.BooleanField(default=False)),
Expand All @@ -43,7 +44,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='MatrixReplicationTarget',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('deleted', models.BooleanField(default=False)),
Expand Down
9 changes: 7 additions & 2 deletions fractal_database_matrix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def get_creds(self) -> Union[MatrixCredentials, InMemoryMatrixCredentials]:
current_db = Database.current_db()
current_device = Device.current_device()
if current_db.is_root:
return self.matrixcredentials_set.get(device=current_device)
try:
return self.matrixcredentials_set.get(device=current_device)
except MatrixCredentials.DoesNotExist as err:
raise Exception(f"Matrix credentials not found for {self}: {err}")

else:
try:
return InMemoryMatrixCredentials(
Expand Down Expand Up @@ -80,7 +84,8 @@ async def push_replication_log(self, fixture: List[Dict[str, Any]]) -> None:

room_id = self.metadata["room_id"]
logger.info(
"Target %s is pushing fixture(s): %s to room %s" % (self, replication_event, room_id)
"Target %s is pushing fixture(s): %s to room %s on homeserver %s"
% (self, replication_event, room_id, self.homeserver)
)
creds = await self.aget_creds()
broker = MatrixBroker().with_matrix_config(
Expand Down

0 comments on commit e5af022

Please sign in to comment.