Skip to content

refactor(logging): consolidate logging setup into shared helper in goose crate - #8817

Merged
DOsinga merged 4 commits into
aaif-goose:mainfrom
r0x0d:chore/consolidate-logging-setup
May 13, 2026
Merged

refactor(logging): consolidate logging setup into shared helper in goose crate#8817
DOsinga merged 4 commits into
aaif-goose:mainfrom
r0x0d:chore/consolidate-logging-setup

Conversation

@r0x0d

@r0x0d r0x0d commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extracts the duplicated file-appender / env-filter / layer-composition logic shared between goose-cli and goose-server into a new build_logging_subscriber() function in crates/goose/src/logging.rs.
  • Introduces LoggingConfig struct with fields: component, name, extra_directives, and console (the only behavioural difference between CLI and server).
  • Adds tracing-appender and tracing-subscriber (with env-filter, fmt, json, time features) to goose's dependencies so the shared code compiles.
  • Reduces duplication by ~80 lines across the two logging modules.
  • All existing logging tests continue to pass.

…ose crate

Move the duplicated file-appender / env-filter / layer-composition logic
from goose-cli and goose-server into a new build_logging_subscriber()
helper in crates/goose/src/logging.rs. Both callers now delegate to the
shared LoggingConfig struct, eliminating ~80 lines of duplication.

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9b0e362a3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +32 to +34
for directive in extra_directives {
if let Ok(d) = directive.parse() {
filter = filter.add_directive(d);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply extra directives only for fallback filter

build_env_filter now appends extra_directives even when RUST_LOG is explicitly set, which changes prior CLI/server behavior where those target directives were only defaults when env parsing failed. In practice, settings like RUST_LOG=error can no longer suppress goose_cli/goose_server info logs because the appended target directives re-enable them, so explicit operator overrides are no longer respected. Restrict these extra directives to the fallback path (or only when RUST_LOG is absent/invalid) to keep RUST_LOG authoritative.

Useful? React with 👍 / 👎.

Douwe Osinga added 2 commits May 11, 2026 18:50
Signed-off-by: Douwe Osinga <douwe@squareup.com>
…fig for file layer format

- Address Codex review: extra_directives are now only appended to the
  fallback filter, not when RUST_LOG is explicitly set
- Preserve server's original plain-text file log format by adding a
  'json' field to LoggingConfig (CLI uses json=true, server uses json=false)

Signed-off-by: Douwe Osinga <douwe@squareup.com>

@DOsinga DOsinga 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.

Pushed a fix commit that addresses two issues:

  1. Codex review feedback: extra_directives are now only applied in the fallback path (when RUST_LOG is not set). Previously they were unconditionally appended, which meant RUST_LOG=error couldn't fully suppress component-specific targets.

  2. Server log format preservation: Added a json field to LoggingConfig. The server's file layer originally used plain text (.with_file(true)), not JSON. The shared code now respects this — CLI gets json: true, server gets json: false.

Also merged origin/main and resolved the Cargo.toml conflict.

Now that logging setup lives in the goose crate, these crates no longer
depend on tracing-appender directly.

Signed-off-by: Douwe Osinga <douwe@squareup.com>
@DOsinga
DOsinga added this pull request to the merge queue May 13, 2026
Merged via the queue into aaif-goose:main with commit 4de5fcd May 13, 2026
22 checks passed
lifeizhou-ap added a commit that referenced this pull request May 14, 2026
* main: (66 commits)
  Switch GH pages deploy to actions/artifact workflow (#9025)
  fix(summon): re-apply canonical limits when delegate overrides model (#9183)
  Split code signing from build (#8587)
  refactor(logging): consolidate logging setup into shared helper in goose crate (#8817)
  fix(cli): report cumulative total_tokens in stream-json/json output (#8910)
  plugins: add open plugins (just skills for now) (#9063)
  fix(providers): refresh GCP metadata server token on expiration (#8929)
  chore(deps): bump the cargo-minor-and-patch group across 1 directory with 14 updates (#9178)
  chore(deps): bump bzip2 from 0.5.2 to 0.6.1 (#8964)
  chore(deps): bump tauri from 2.10.3 to 2.11.1 in /ui/goose2/src-tauri (#9066)
  chore(deps): bump hono from 4.12.14 to 4.12.18 in /evals/open-model-gym/mcp-harness (#9073)
  localize hardcoded strings in provider settings UI (#8931)
  chore(deps): bump @babel/plugin-transform-modules-systemjs from 7.28.5 to 7.29.4 in /documentation (#9122)
  move settings into app shell (#9047)
  Add Location column to CLI skills table (#8785)
  (feat): add routstr as a declarative provider (#9175)
  Add FuturMix provider (#8840)
  fix: convert quoted numeric config values to numbers if needed (#8844)
  fix(ui): keep SSE reconnect loop alive on long disconnects (#8717) (#8846)
  fix(openai): apply request_params to outgoing API payload (#9151)
  ...
shafqatevo pushed a commit to shafqatevo/goose that referenced this pull request Aug 7, 2026
…ose crate (aaif-goose#8817)

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
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