Skip to content

refactor(http,llm): Using new Logger module from core#287

Open
szanata wants to merge 4 commits into
mainfrom
refactor/use_logger
Open

refactor(http,llm): Using new Logger module from core#287
szanata wants to merge 4 commits into
mainfrom
refactor/use_logger

Conversation

@szanata

@szanata szanata commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Refactored LLM and HTTP to use new Logger from Core module in place of console.*.

Test plan

  • Unit tests refactored
  • Manually tested

@bnchrch bnchrch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing: the refactor dropped the log assertions instead of pointing them at Logger, so a few "we warn on X" behaviors are now untested (inline). Couple of nits too.

@@ -78,7 +76,6 @@ describe( 'calculateLLMCallCost', () => {
} );

expect( result ).toBeNull();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 The swap dropped the log checks instead of moving them to Logger, so we no longer test that these warnings fire:

  • Failed to fetch models pricing and Missing cost reference for model (this file)
  • the error log in the catch (this file)
  • the no-cache / stale-cache warnings in fetch_models_pricing.spec.js
  • the snake_case warning in validations.spec.js
  • the warn / no-warn checks in http/cost.spec.ts

In tests Logger.* falls back to console.log, so a console.log spy works, or mock @outputai/core's Logger. If we've decided log lines aren't worth testing that's fine, I'd just want it on purpose, not a side effect of the swap.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed on purpose, as I dont think those are worth checking...

Comment thread sdk/llm/src/prompt/validations.js Outdated
@@ -1,5 +1,6 @@
import { ValidationError, z } from '@outputai/core';
import { attributesSchema } from './block_options.js';
import { Logger } from '@outputai/core';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💅 @outputai/core gets imported twice now (line 1 and here). Merge them:

import { ValidationError, z, Logger } from '@outputai/core';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad

Comment thread sdk/llm/src/cost/index.js Outdated

if ( !models ) {
console.warn( 'Failed to fetch models pricing' );
Logger.warn( 'Failed to fetch models pricing' );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger has no namespace, so these land under the generic Activity logs with nothing saying they came from llm cost. validations.js keeps its [output-llm] prefix but these don't, so it's a bit inconsistent. Worth a short prefix here too so they stay traceable? Small.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this isnt ideal. I am adding namespace overwriting on the Logger.

@szanata szanata force-pushed the refactor/use_logger branch from 311062a to 9162c95 Compare June 25, 2026 17:23
@mintlify

mintlify Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
outputai 🟢 Ready View Preview Jun 25, 2026, 5:24 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

The namespace can be customized by setting it in the metadata:

```js
Logger.warn('My awesome message', { namespace: 'Custom' });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ wdyt about being able to apply name spaces across all instances? e.g.

HttpLogger = new Logger("http")
HttpLogger.warn("foo")

or

HttpLogger = Logger.createLogger("http")
HttpLogger.warn("foo")

Seems both more familiar, prevent us from having to remember in each package at each log line what name space to add, and would prevent having the collission issue with the key "namespace:"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would steer away from both. I think the is very convenient to be able to just Logger.*() at any point, without dealing with instances. We could have a .bindNamespace() module that returns a logger "instance" with the namespace already set.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Make de the default Logger an instance with a .createLogger() that creates another instance with bound namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants