Skip to content

Commit ab5a759

Browse files
authored
Merge pull request #9157 from Couchers-org/backend/feature/admin-action-level-trace
Backend: add TRACE level to AdminActionLevel
2 parents 3489da0 + 1cddc40 commit ab5a759

5 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Add trace to AdminActionLevel
2+
3+
Revision ID: 0169
4+
Revises: 0168
5+
Create Date: 2026-06-20 00:00:00.000000
6+
7+
"""
8+
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "0169"
13+
down_revision = "0168"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
# 'trace' sorts below 'debug' so the enum's intrinsic ordering matches its severity
20+
op.execute("ALTER TYPE adminactionlevel ADD VALUE IF NOT EXISTS 'trace' BEFORE 'debug'")
21+
22+
23+
def downgrade() -> None:
24+
# PostgreSQL cannot drop a value from an enum type, so this is a no-op.
25+
pass

app/backend/src/couchers/models/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
class AdminActionLevel(enum.Enum):
26+
trace = enum.auto()
2627
debug = enum.auto()
2728
normal = enum.auto()
2829
high = enum.auto()

app/backend/src/couchers/servicers/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@
7777

7878

7979
adminactionlevel2api = {
80+
AdminActionLevel.trace: admin_pb2.ADMIN_ACTION_LEVEL_TRACE,
8081
AdminActionLevel.debug: admin_pb2.ADMIN_ACTION_LEVEL_DEBUG,
8182
AdminActionLevel.normal: admin_pb2.ADMIN_ACTION_LEVEL_NORMAL,
8283
AdminActionLevel.high: admin_pb2.ADMIN_ACTION_LEVEL_HIGH,
8384
}
8485

8586
api2adminactionlevel = {
87+
admin_pb2.ADMIN_ACTION_LEVEL_TRACE: AdminActionLevel.trace,
8688
admin_pb2.ADMIN_ACTION_LEVEL_DEBUG: AdminActionLevel.debug,
8789
admin_pb2.ADMIN_ACTION_LEVEL_NORMAL: AdminActionLevel.normal,
8890
admin_pb2.ADMIN_ACTION_LEVEL_HIGH: AdminActionLevel.high,

app/backend/src/tests/test_admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,17 @@ def test_admin_actions_level(db):
12771277
assert len(res.admin_actions) == 3
12781278
assert res.admin_actions[2].level == admin_pb2.ADMIN_ACTION_LEVEL_HIGH
12791279

1280+
# Explicitly set to TRACE
1281+
res = api.AddAdminNote(
1282+
admin_pb2.AddAdminNoteReq(
1283+
user=normal_user.username,
1284+
admin_note="trace note",
1285+
level=admin_pb2.ADMIN_ACTION_LEVEL_TRACE,
1286+
)
1287+
)
1288+
assert len(res.admin_actions) == 4
1289+
assert res.admin_actions[3].level == admin_pb2.ADMIN_ACTION_LEVEL_TRACE
1290+
12801291

12811292
def test_admin_actions_on_mutations(db, push_collector: PushCollector):
12821293
super_user, super_token = generate_user(is_superuser=True)

app/proto/admin.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import "api.proto";
1111

1212
enum AdminActionLevel {
1313
ADMIN_ACTION_LEVEL_UNSPECIFIED = 0;
14+
ADMIN_ACTION_LEVEL_TRACE = 4; // firehose, below debug
1415
ADMIN_ACTION_LEVEL_DEBUG = 1; // low-importance chatter
1516
ADMIN_ACTION_LEVEL_NORMAL = 2; // regular admin work
1617
ADMIN_ACTION_LEVEL_HIGH = 3; // significant state changes

0 commit comments

Comments
 (0)