Skip to content

fix(logger): migrate to winston for simpler executable support#1808

Merged
tejaskash merged 4 commits into
aws:refactorfrom
Hweinstock:feat/logging-winston
Jul 22, 2026
Merged

fix(logger): migrate to winston for simpler executable support#1808
tejaskash merged 4 commits into
aws:refactorfrom
Hweinstock:feat/logging-winston

Conversation

@Hweinstock

@Hweinstock Hweinstock commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

#1801

This PR goes with option 3 from the issue link.

The original attempt lives in #1804, however there were some issues in that PR:

  • a bug that causes logs to inconsistently show up after executing commands due to flush behavior on pino due how we manually manage the output stream.
  • manually maintaining a type definition for an external dependency.
  • CI job organization wasn't clear (compile vs build?).

Solution

  • switch to winston rotating logger since it avoids the complexity of handling the stream ourselves. Winston puts it in the main thread by default.
  • switch to organizing CI checks into build and check to mirror what cargo does. Specifically,check does static analysis without producing any artifacts, whereas build compiles, packs, and produces the build artifacts.

Testing

  • CI now verifies the compiled binary is working.
  • logging tests passes, and verified locally:
rm -rf ~/.agentcore/logs
./dist/bin/agentcore-linux-x64 config k1 k2
cat ~/.agentcore/logs/output-2026-07-22.log

{"level":"debug","msg":"executing command","time":1784752392752,"cliSessionId":"7458c0f4-216a-464e-b68f-28441d229d1e","commandPath":"/agentcore/config","flags":{},"args":{"k
ey":"k1","value":"k2"}}
{"level":"debug","msg":"command executed successfully","time":1784752392753,"cliSessionId":"7458c0f4-216a-464e-b68f-28441d229d1e","commandPath":"/agentcore/config"}

Notes

  • try to not to squash merge since this PR includes a few components that may be useful as separate commits in the commit history.

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jul 22, 2026
@Hweinstock
Hweinstock force-pushed the feat/logging-winston branch from 2928035 to bb569a1 Compare July 22, 2026 18:54
@Hweinstock
Hweinstock force-pushed the feat/logging-winston branch from bb569a1 to e1ee9ed Compare July 22, 2026 18:57
@Hweinstock
Hweinstock force-pushed the feat/logging-winston branch 2 times, most recently from e5b41ad to 5fd0c5d Compare July 22, 2026 20:20
@Hweinstock
Hweinstock force-pushed the feat/logging-winston branch from 5fd0c5d to 3759362 Compare July 22, 2026 20:26
export function createFileLogger(config: FileLoggerConfig): AsyncLogger {
const maxSizeInMB = config.maxSizeInMB ?? 10;
const maxFileCount = config.maxFileCount ?? 5;
const maxSizeInMB = config.maxSizeInMB ?? 5;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the new behavior is that it rotates the file each day or when the size cap it hit. Before we rotated only when the size limit was hit. This swap ensures we maintain roughly the past 10 days but still no more than 50MB.

Comment thread src/index.ts
await rootHandler.route(argv);
} catch (e) {
const error = e instanceof Error ? e : new Error(String(e));
io.stderr.write(`${error.name}: ${error.message}\n`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to top-level to ensure that logger/io init failures are logged to console.

@Hweinstock
Hweinstock marked this pull request as ready for review July 22, 2026 20:37
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.92%. Comparing base (951044e) to head (3759362).
⚠️ Report is 1 commits behind head on refactor.

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #1808   +/-   ##
=========================================
  Coverage     93.91%   93.92%           
=========================================
  Files           118      118           
  Lines          6423     6432    +9     
=========================================
+ Hits           6032     6041    +9     
  Misses          391      391           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tejaskash
tejaskash merged commit 56f62e7 into aws:refactor Jul 22, 2026
8 checks passed
@Hweinstock
Hweinstock deleted the feat/logging-winston branch July 22, 2026 21:01
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.

4 participants