Skip to content

Commit 37226b0

Browse files
s
1 parent fdb05c0 commit 37226b0

8 files changed

Lines changed: 32 additions & 36 deletions

File tree

packages/backend/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Api {
4242
app.post(`/api/experimental/add-github-repo`, this.experimental_addGithubRepo.bind(this));
4343

4444
this.server = app.listen(PORT, () => {
45-
logger.info(`API server is running on port ${PORT}`);
45+
logger.debug(`API server is running on port ${PORT}`);
4646
});
4747
}
4848

packages/backend/src/configManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ConfigManager {
2828
});
2929

3030
this.watcher.on('change', async () => {
31-
logger.info(`Config file ${configPath} changed. Syncing config.`);
31+
logger.debug(`Config file ${configPath} changed. Syncing config.`);
3232
try {
3333
await this.syncConfig(configPath);
3434
} catch (error) {
@@ -101,7 +101,7 @@ export class ConfigManager {
101101
});
102102

103103
if (connectionNeedsSyncing) {
104-
logger.info(`Change detected for connection '${key}' (id: ${connection.id}). Creating sync job.`);
104+
logger.debug(`Change detected for connection '${key}' (id: ${connection.id}). Creating sync job.`);
105105
await this.connectionManager.createJobs([connection]);
106106
}
107107
}
@@ -119,7 +119,7 @@ export class ConfigManager {
119119
});
120120

121121
for (const connection of deletedConnections) {
122-
logger.info(`Deleting connection with name '${connection.name}'. Connection ID: ${connection.id}`);
122+
logger.debug(`Deleting connection with name '${connection.name}'. Connection ID: ${connection.id}`);
123123
await this.db.connection.delete({
124124
where: {
125125
id: connection.id,

packages/backend/src/connectionManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class ConnectionManager {
137137
});
138138

139139
for (const job of jobs) {
140-
logger.info(`Scheduling job ${job.id} for connection ${job.connection.name} (id: ${job.connectionId})`);
140+
logger.debug(`Scheduling job ${job.id} for connection ${job.connection.name} (id: ${job.connectionId})`);
141141
await this.queue.add(
142142
'connection-sync-job',
143143
{
@@ -158,7 +158,7 @@ export class ConnectionManager {
158158
private async runJob(job: Job<JobPayload>): Promise<JobResult> {
159159
const { jobId, connectionName } = job.data;
160160
const logger = createJobLogger(jobId);
161-
logger.info(`Running connection sync job ${jobId} for connection ${connectionName} (id: ${job.data.connectionId})`);
161+
logger.debug(`Running connection sync job ${jobId} for connection ${connectionName} (id: ${job.data.connectionId})`);
162162

163163
const currentStatus = await this.db.connectionSyncJob.findUniqueOrThrow({
164164
where: {
@@ -261,7 +261,7 @@ export class ConnectionManager {
261261
}
262262
});
263263
const deleteDuration = performance.now() - deleteStart;
264-
logger.info(`Deleted all RepoToConnection records for connection ${connectionName} (id: ${job.data.connectionId}) in ${deleteDuration}ms`);
264+
logger.debug(`Deleted all RepoToConnection records for connection ${connectionName} (id: ${job.data.connectionId}) in ${deleteDuration}ms`);
265265

266266
const totalUpsertStart = performance.now();
267267
for (const repo of repoData) {
@@ -281,7 +281,7 @@ export class ConnectionManager {
281281
logger.debug(`Upserted repo ${repo.displayName} (id: ${repo.external_id}) in ${upsertDuration}ms`);
282282
}
283283
const totalUpsertDuration = performance.now() - totalUpsertStart;
284-
logger.info(`Upserted ${repoData.length} repos for connection ${connectionName} (id: ${job.data.connectionId}) in ${totalUpsertDuration}ms`);
284+
logger.debug(`Upserted ${repoData.length} repos for connection ${connectionName} (id: ${job.data.connectionId}) in ${totalUpsertDuration}ms`);
285285
}, { timeout: env.CONNECTION_MANAGER_UPSERT_TIMEOUT_MS });
286286

287287
return {
@@ -330,7 +330,7 @@ export class ConnectionManager {
330330
}
331331
}
332332

333-
logger.info(`Connection sync job ${job.id} for connection ${job.data.connectionName} (id: ${job.data.connectionId}) completed`);
333+
logger.debug(`Connection sync job ${job.id} for connection ${job.data.connectionName} (id: ${job.data.connectionId}) completed`);
334334

335335
this.promClient.activeConnectionSyncJobs.dec({ connection: connectionName });
336336
this.promClient.connectionSyncJobSuccessTotal.inc({ connection: connectionName });

packages/backend/src/ee/auditLogPruner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AuditLogPruner {
2323
return;
2424
}
2525

26-
logger.info(`Audit log pruner started. Retaining logs for ${env.SOURCEBOT_EE_AUDIT_RETENTION_DAYS} days.`);
26+
logger.debug(`Audit log pruner started. Retaining logs for ${env.SOURCEBOT_EE_AUDIT_RETENTION_DAYS} days.`);
2727

2828
// Run immediately on startup, then every 24 hours
2929
this.pruneOldAuditLogs();
@@ -41,7 +41,7 @@ export class AuditLogPruner {
4141
const cutoff = new Date(Date.now() - env.SOURCEBOT_EE_AUDIT_RETENTION_DAYS * ONE_DAY_MS);
4242
let totalDeleted = 0;
4343

44-
logger.info(`Pruning audit logs older than ${cutoff.toISOString()}...`);
44+
logger.debug(`Pruning audit logs older than ${cutoff.toISOString()}...`);
4545

4646
// Delete in batches to avoid long-running transactions
4747
while (true) {
@@ -63,9 +63,9 @@ export class AuditLogPruner {
6363
}
6464

6565
if (totalDeleted > 0) {
66-
logger.info(`Pruned ${totalDeleted} audit log records.`);
66+
logger.debug(`Pruned ${totalDeleted} audit log records.`);
6767
} else {
68-
logger.info('No audit log records to prune.');
68+
logger.debug('No audit log records to prune.');
6969
}
7070
}
7171
}

packages/backend/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const prisma = new PrismaClient({
4141

4242
try {
4343
await redis.ping();
44-
logger.info('Connected to redis');
44+
logger.debug('Connected to redis');
4545
} catch (err: unknown) {
4646
logger.error('Failed to connect to redis. Error:', err);
4747
process.exit(1);

packages/backend/src/repoIndexManager.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export class RepoIndexManager {
279279
private async runJob(job: Job<JobPayload>, signal: AbortSignal) {
280280
const id = job.data.jobId;
281281
const logger = createJobLogger(id);
282-
logger.info(`Running ${job.data.type} job ${id} for repo ${job.data.repoName} (id: ${job.data.repoId})`);
282+
logger.debug(`Running ${job.data.type} job ${id} for repo ${job.data.repoName} (id: ${job.data.repoId})`);
283283

284284
const currentStatus = await this.db.repoIndexingJob.findUniqueOrThrow({
285285
where: {
@@ -383,7 +383,7 @@ export class RepoIndexManager {
383383
signal,
384384
});
385385

386-
logger.info(`Fetching ${repo.name} (id: ${repo.id})...`);
386+
logger.debug(`Fetching ${repo.name} (id: ${repo.id})...`);
387387
const { durationMs } = await measure(() => fetchRepository({
388388
cloneUrl: cloneUrlMaybeWithToken,
389389
authHeader,
@@ -395,10 +395,9 @@ export class RepoIndexManager {
395395
}));
396396
const fetchDuration_s = durationMs / 1000;
397397

398-
process.stdout.write('\n');
399-
logger.info(`Fetched ${repo.name} (id: ${repo.id}) in ${fetchDuration_s}s`);
398+
logger.debug(`Fetched ${repo.name} (id: ${repo.id}) in ${fetchDuration_s}s`);
400399
} else if (!isReadOnly) {
401-
logger.info(`Cloning ${repo.name} (id: ${repo.id})...`);
400+
logger.debug(`Cloning ${repo.name} (id: ${repo.id})...`);
402401

403402
const { durationMs } = await measure(() => cloneRepository({
404403
cloneUrl: cloneUrlMaybeWithToken,
@@ -411,8 +410,7 @@ export class RepoIndexManager {
411410
}));
412411
const cloneDuration_s = durationMs / 1000;
413412

414-
process.stdout.write('\n');
415-
logger.info(`Cloned ${repo.name} (id: ${repo.id}) in ${cloneDuration_s}s`);
413+
logger.debug(`Cloned ${repo.name} (id: ${repo.id}) in ${cloneDuration_s}s`);
416414
}
417415

418416
// Regardless of clone or fetch, always upsert the git config for the repo.
@@ -478,11 +476,11 @@ export class RepoIndexManager {
478476
revisions = revisions.slice(0, 64);
479477
}
480478

481-
logger.info(`Indexing ${repo.name} (id: ${repo.id})...`);
479+
logger.debug(`Indexing ${repo.name} (id: ${repo.id})...`);
482480
try {
483481
const { durationMs } = await measure(() => indexGitRepository(repo, this.settings, revisions, signal));
484482
const indexDuration_s = durationMs / 1000;
485-
logger.info(`Indexed ${repo.name} (id: ${repo.id}) in ${indexDuration_s}s`);
483+
logger.debug(`Indexed ${repo.name} (id: ${repo.id}) in ${indexDuration_s}s`);
486484
} catch (error) {
487485
// Clean up any temporary shard files left behind by the failed indexing operation.
488486
// Zoekt creates .tmp files during indexing which can accumulate if indexing fails repeatedly.
@@ -497,15 +495,15 @@ export class RepoIndexManager {
497495
private async cleanupRepository(repo: Repo, logger: Logger) {
498496
const { path: repoPath, isReadOnly } = getRepoPath(repo);
499497
if (existsSync(repoPath) && !isReadOnly) {
500-
logger.info(`Deleting repo directory ${repoPath}`);
498+
logger.debug(`Deleting repo directory ${repoPath}`);
501499
await rm(repoPath, { recursive: true, force: true });
502500
}
503501

504502
const shardPrefix = getShardPrefix(repo.orgId, repo.id);
505503
const files = (await readdir(INDEX_CACHE_DIR)).filter(file => file.startsWith(shardPrefix));
506504
for (const file of files) {
507505
const filePath = `${INDEX_CACHE_DIR}/${file}`;
508-
logger.info(`Deleting shard file ${filePath}`);
506+
logger.debug(`Deleting shard file ${filePath}`);
509507
await rm(filePath, { force: true });
510508
}
511509
}
@@ -564,14 +562,14 @@ export class RepoIndexManager {
564562
}
565563
});
566564

567-
logger.info(`Completed index job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id})`);
565+
logger.debug(`Completed index job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id})`);
568566
}
569567
else if (jobData.type === RepoIndexingJobType.CLEANUP) {
570568
const repo = await this.db.repo.delete({
571569
where: { id: jobData.repoId },
572570
});
573571

574-
logger.info(`Completed cleanup job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id})`);
572+
logger.debug(`Completed cleanup job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id})`);
575573
}
576574

577575
// Track metrics for successful job
@@ -604,7 +602,7 @@ export class RepoIndexManager {
604602
// or if it is being retried.
605603
const jobState = await job.getState();
606604
if (jobState !== 'failed') {
607-
jobLogger.warn(`Job ${job.id} for repo ${job.data.repoName} (id: ${job.data.repoId}) failed. Retrying...`);
605+
jobLogger.warn(`Job ${job.id} for repo ${job.data.repoName} (id: ${job.data.repoId}) failed. Retrying... Reason: ${error.message}`);
608606
return;
609607
}
610608

@@ -626,7 +624,7 @@ export class RepoIndexManager {
626624
this.promClient.activeRepoIndexJobs.dec({ repo: job.data.repoName, type: jobTypeLabel });
627625
this.promClient.repoIndexJobFailTotal.inc({ repo: job.data.repoName, type: jobTypeLabel });
628626

629-
jobLogger.error(`Failed job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id}).`);
627+
jobLogger.error(`Failed job ${job.data.jobId} for repo ${repo.name} (id: ${repo.id}). Reason: ${error.message}`);
630628

631629
captureEvent('backend_repo_index_job_failed', {
632630
repoId: job.data.repoId,
@@ -664,7 +662,7 @@ export class RepoIndexManager {
664662
const existingIds = new Set(existingRepos.map(r => r.id));
665663
for (const [repoId, repoPath] of repoIdToPath) {
666664
if (!existingIds.has(repoId)) {
667-
logger.info(`Removing orphaned repo directory with no DB record: ${repoPath}`);
665+
logger.debug(`Removing orphaned repo directory with no DB record: ${repoPath}`);
668666
await rm(repoPath, { recursive: true, force: true });
669667
}
670668
}
@@ -695,7 +693,7 @@ export class RepoIndexManager {
695693
if (!existingIds.has(repoId)) {
696694
for (const entry of shards) {
697695
const shardPath = `${INDEX_CACHE_DIR}/${entry}`;
698-
logger.info(`Removing orphaned index shard with no DB record: ${shardPath}`);
696+
logger.debug(`Removing orphaned index shard with no DB record: ${shardPath}`);
699697
await rm(shardPath, { force: true });
700698
}
701699
}

packages/backend/src/zoekt.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ export const indexGitRepository = async (repo: Repo, settings: Settings, revisio
3737

3838
if (stdout) {
3939
stdout.split('\n').filter(line => line.trim()).forEach(line => {
40-
logger.info(line);
40+
logger.debug(line);
4141
});
4242
}
4343
if (stderr) {
4444
stderr.split('\n').filter(line => line.trim()).forEach(line => {
45-
// TODO: logging as regular info here and not error because non error logs are being
46-
// streamed in stderr and incorrectly being logged as errors at a high level
47-
logger.info(line);
45+
logger.debug(line);
4846
});
4947
}
5048

packages/web/src/app/api/(server)/health/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createLogger } from "@sourcebot/shared";
66
const logger = createLogger('health-check');
77

88
export const GET = apiHandler(async () => {
9-
logger.info('health check');
9+
logger.debug('health check');
1010
return Response.json({ status: 'ok' });
1111
}, { track: false });
1212

0 commit comments

Comments
 (0)