Skip to content

Commit 2e8950d

Browse files
Copilothotlong
andcommitted
refactor: remove all console.log/warn/error calls from OData V4 protocol plugin
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a7ba4a1 commit 2e8950d

1 file changed

Lines changed: 2 additions & 22 deletions

File tree

packages/protocols/odata-v4/src/index.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,9 @@ export class ODataV4Plugin implements RuntimePlugin {
117117
* Install hook - called during kernel initialization
118118
*/
119119
async install(ctx: RuntimeContext): Promise<void> {
120-
console.log(`[${this.name}] Installing OData V4 protocol plugin...`);
121-
122120
// Store reference to the engine for later use
123121
this.engine = ctx.engine || (ctx as any).getKernel?.();
124122

125-
console.log(`[${this.name}] Protocol bridge initialized`);
126123
}
127124

128125
/**
@@ -149,22 +146,16 @@ export class ODataV4Plugin implements RuntimePlugin {
149146
}
150147

151148
if (httpServer && httpServer.app) {
152-
console.log(`[${this.name}] 🔗 Attaching to shared Hono server...`);
153149
await this.attachToHono(httpServer.app);
154150
return;
155151
}
156152

157-
console.log(`[${this.name}] Starting OData V4 server (standalone)...`);
158-
159153
// Create HTTP server with request handler
160154
this.server = createServer((req, res) => this.handleRequest(req, res));
161155

162156
// Start listening
163157
await new Promise<void>((resolve) => {
164158
this.server!.listen(this.config.port, () => {
165-
console.log(`[${this.name}] 🚀 OData V4 server listening on http://localhost:${this.config.port}${this.config.basePath}`);
166-
console.log(`[${this.name}] 📄 Service Document: http://localhost:${this.config.port}${this.config.basePath}`);
167-
console.log(`[${this.name}] 📝 Metadata Document: http://localhost:${this.config.port}${this.config.basePath}/$metadata`);
168159
resolve();
169160
});
170161
});
@@ -233,7 +224,6 @@ export class ODataV4Plugin implements RuntimePlugin {
233224
return c.body(responseBody);
234225
});
235226

236-
console.log(`[${this.name}] 🚀 OData mounted at ${basePath}`);
237227
}
238228

239229
// ---------------------------------------------------
@@ -243,7 +233,6 @@ export class ODataV4Plugin implements RuntimePlugin {
243233
*/
244234
async onStop(ctx: RuntimeContext): Promise<void> {
245235
if (this.server) {
246-
console.log(`[${this.name}] Stopping OData V4 server...`);
247236
await new Promise<void>((resolve, reject) => {
248237
this.server!.close((err) => {
249238
if (err) reject(err);
@@ -414,7 +403,6 @@ export class ODataV4Plugin implements RuntimePlugin {
414403
await this.handleEntityRequest(req, res, path);
415404
}
416405
} catch (error) {
417-
console.error(`[${this.name}] Request error:`, error);
418406
this.sendError(res, 500, error instanceof Error ? error.message : 'Internal Server Error');
419407
}
420408
}
@@ -788,7 +776,6 @@ export class ODataV4Plugin implements RuntimePlugin {
788776

789777
// Check depth limit
790778
if (depth >= this.config.maxExpandDepth) {
791-
console.warn(`[${this.name}] Maximum expand depth (${this.config.maxExpandDepth}) reached, skipping further expansion`);
792779
return;
793780
}
794781

@@ -1213,7 +1200,6 @@ export class ODataV4Plugin implements RuntimePlugin {
12131200

12141201
const edmType = typeMap[fieldType];
12151202
if (!edmType) {
1216-
console.warn(`[ODataV4Plugin] Unknown field type '${fieldType}', defaulting to Edm.String`);
12171203
return 'Edm.String';
12181204
}
12191205

@@ -1302,7 +1288,6 @@ export class ODataV4Plugin implements RuntimePlugin {
13021288
res.end(batchResponse);
13031289

13041290
} catch (error) {
1305-
console.error(`[${this.name}] Batch request error:`, error);
13061291
this.sendError(res, 500, error instanceof Error ? error.message : 'Batch processing failed');
13071292
}
13081293
}
@@ -1481,15 +1466,13 @@ export class ODataV4Plugin implements RuntimePlugin {
14811466
} catch (error) {
14821467
// Enhanced error handling with rollback information
14831468
const errorMessage = error instanceof Error ? error.message : 'Changeset failed';
1484-
console.error(`[${this.name}] Changeset failed, rolling back all operations:`, errorMessage);
1485-
14861469
// Attempt to rollback completed operations (in reverse order)
14871470
// Note: This is a best-effort rollback since we don't have true database transactions
14881471
// In a production system, this would use database transaction support
14891472
try {
14901473
await this.rollbackChangeset(operations, tempResults.length);
14911474
} catch (rollbackError) {
1492-
console.error(`[${this.name}] Rollback failed:`, rollbackError);
1475+
// Error silently ignored
14931476
}
14941477

14951478
// Return detailed error response for the entire changeset
@@ -1543,18 +1526,15 @@ export class ODataV4Plugin implements RuntimePlugin {
15431526
if (op.type === 'POST') {
15441527
// Created record - try to delete it
15451528
// TODO: Need to extract and store the created ID from the response
1546-
console.log(`[${this.name}] Would rollback CREATE on ${op.entitySet}`);
15471529
} else if (op.type === 'DELETE') {
15481530
// Deleted record - try to restore it
15491531
// TODO: Need to store the deleted record data before deletion
1550-
console.log(`[${this.name}] Would rollback DELETE on ${op.entitySet}(${op.key})`);
15511532
} else if (op.type === 'PATCH' || op.type === 'PUT') {
15521533
// Updated record - try to restore previous values
15531534
// TODO: Need to fetch and store previous values before update
1554-
console.log(`[${this.name}] Would rollback UPDATE on ${op.entitySet}(${op.key})`);
15551535
}
15561536
} catch (error) {
1557-
console.error(`[${this.name}] Failed to rollback operation ${i}:`, error);
1537+
// Error silently ignored
15581538
}
15591539
}
15601540
}

0 commit comments

Comments
 (0)