Skip to content

Commit 0fae75a

Browse files
authored
fix(opencode): add logger to LiteLLMPricingFetcher (#789)
1 parent ae115c3 commit 0fae75a

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

apps/opencode/src/commands/daily.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {
99
import { groupBy } from 'es-toolkit';
1010
import { define } from 'gunshi';
1111
import pc from 'picocolors';
12-
import { calculateCostForEntry } from '../cost-utils';
13-
import { loadOpenCodeMessages } from '../data-loader';
12+
import { calculateCostForEntry } from '../cost-utils.ts';
13+
import { loadOpenCodeMessages } from '../data-loader.ts';
14+
import { logger } from '../logger.ts';
1415

1516
const TABLE_COLUMN_COUNT = 8;
1617

@@ -42,7 +43,7 @@ export const dailyCommand = define({
4243
return;
4344
}
4445

45-
using fetcher = new LiteLLMPricingFetcher({ offline: false });
46+
using fetcher = new LiteLLMPricingFetcher({ offline: false, logger });
4647

4748
const entriesByDate = groupBy(entries, (entry) => entry.timestamp.toISOString().split('T')[0]!);
4849

apps/opencode/src/commands/monthly.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {
99
import { groupBy } from 'es-toolkit';
1010
import { define } from 'gunshi';
1111
import pc from 'picocolors';
12-
import { calculateCostForEntry } from '../cost-utils';
13-
import { loadOpenCodeMessages } from '../data-loader';
12+
import { calculateCostForEntry } from '../cost-utils.ts';
13+
import { loadOpenCodeMessages } from '../data-loader.ts';
14+
import { logger } from '../logger.ts';
1415

1516
const TABLE_COLUMN_COUNT = 8;
1617

@@ -42,7 +43,7 @@ export const monthlyCommand = define({
4243
return;
4344
}
4445

45-
using fetcher = new LiteLLMPricingFetcher({ offline: false });
46+
using fetcher = new LiteLLMPricingFetcher({ offline: false, logger });
4647

4748
const entriesByMonth = groupBy(entries, (entry) => entry.timestamp.toISOString().slice(0, 7));
4849

apps/opencode/src/commands/session.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {
99
import { groupBy } from 'es-toolkit';
1010
import { define } from 'gunshi';
1111
import pc from 'picocolors';
12-
import { calculateCostForEntry } from '../cost-utils';
13-
import { loadOpenCodeMessages, loadOpenCodeSessions } from '../data-loader';
12+
import { calculateCostForEntry } from '../cost-utils.ts';
13+
import { loadOpenCodeMessages, loadOpenCodeSessions } from '../data-loader.ts';
14+
import { logger } from '../logger.ts';
1415

1516
const TABLE_COLUMN_COUNT = 8;
1617

@@ -45,7 +46,7 @@ export const sessionCommand = define({
4546
return;
4647
}
4748

48-
using fetcher = new LiteLLMPricingFetcher({ offline: false });
49+
using fetcher = new LiteLLMPricingFetcher({ offline: false, logger });
4950

5051
const entriesBySession = groupBy(entries, (entry) => entry.sessionID);
5152

apps/opencode/src/commands/weekly.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {
99
import { groupBy } from 'es-toolkit';
1010
import { define } from 'gunshi';
1111
import pc from 'picocolors';
12-
import { calculateCostForEntry } from '../cost-utils';
13-
import { loadOpenCodeMessages } from '../data-loader';
12+
import { calculateCostForEntry } from '../cost-utils.ts';
13+
import { loadOpenCodeMessages } from '../data-loader.ts';
14+
import { logger } from '../logger.ts';
1415

1516
const TABLE_COLUMN_COUNT = 8;
1617

@@ -67,7 +68,7 @@ export const weeklyCommand = define({
6768
return;
6869
}
6970

70-
using fetcher = new LiteLLMPricingFetcher({ offline: false });
71+
using fetcher = new LiteLLMPricingFetcher({ offline: false, logger });
7172

7273
const entriesByWeek = groupBy(entries, (entry) => getISOWeek(entry.timestamp));
7374

apps/opencode/src/logger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createLogger, log as internalLog } from '@ccusage/internal/logger';
2+
3+
import { name } from '../package.json';
4+
5+
export const logger = createLogger(name);
6+
7+
export const log = internalLog;

0 commit comments

Comments
 (0)