Skip to content

Commit 5344c1a

Browse files
author
Lasim
committed
feat(backend): add structured logging to device revocation
1 parent a181560 commit 5344c1a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

services/backend/src/services/deviceService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { devices } from '../db/schema.sqlite';
44
import { nanoid } from 'nanoid';
55
import crypto from 'crypto';
66
import os from 'os';
7+
import type { FastifyBaseLogger } from 'fastify';
78

89
// TypeScript interfaces for type safety
910
export interface DeviceInfo {
@@ -251,7 +252,7 @@ export class DeviceService {
251252
/**
252253
* Revoke device access (mark as inactive and untrusted)
253254
*/
254-
async revokeDevice(deviceId: string, revokedBy: string, reason?: string): Promise<void> {
255+
async revokeDevice(deviceId: string, revokedBy: string, logger: FastifyBaseLogger, reason?: string): Promise<void> {
255256
const now = new Date();
256257

257258
await this.db
@@ -263,8 +264,13 @@ export class DeviceService {
263264
})
264265
.where(eq(devices.id, deviceId));
265266

266-
// TODO: Log security event
267-
console.log(`Device ${deviceId} revoked by ${revokedBy}${reason ? `: ${reason}` : ''}`);
267+
// Log security event with structured logging
268+
logger.warn({
269+
operation: 'device_revoked',
270+
deviceId,
271+
revokedBy,
272+
reason: reason || null
273+
}, `Device ${deviceId} revoked by ${revokedBy}${reason ? `: ${reason}` : ''}`);
268274
}
269275

270276
/**

0 commit comments

Comments
 (0)