Skip to content

Example Brokk.ai-based fix of a bad logging dir on startup#5308

Open
Cervator wants to merge 4 commits intodevelopfrom
brokk/logs-fix
Open

Example Brokk.ai-based fix of a bad logging dir on startup#5308
Cervator wants to merge 4 commits intodevelopfrom
brokk/logs-fix

Conversation

@Cervator
Copy link
Member

@Cervator Cervator commented Feb 11, 2026

Contains

I'm playing with brokk.ai and this is solely a test of a simple bug fix - just getting commits off my test system to see them in a different light. 100% AI including commit after each edit as that's how Brokk does it. Need to look at this with less sleepy eyes to see if it makes sense then tidy up further if so :-)

How to test

When running Terasology from source without this fix you get a badly named logs folder as logging initializes before the folder name is available. Running Terasology with this fix (and that folder from a prior execution deleted) the bad folder should not show up.

Outstanding before merging

  • Is AI work, needs extra shifty eyes and human judgement with extreme prejudice ;-)
  • Brokk tries to generate an AGENTS.md after an initial look at the codebase. It catches a few things but leaves loads of others out. That's a different effort, really - this PR could be redone with a single commit without the AI extras for now.

Note

Low Risk
Small, localized change to startup/log initialization ordering plus repo hygiene files; low risk aside from potential differences in early log location resolution when --homedir is used.

Overview
Fixes a startup ordering issue where Logback could initialize before LoggingContext.initialize(), creating a logFileFolder_IS_UNDEFINED logs directory.

Terasology.call() now computes the log directory directly from --homedir (or .) and initializes logging before handleLaunchArguments() loads PathManager; setupLogging() is updated to accept an explicit Path, and early homeDir diagnostics switch from SLF4J to System.out.

Also adds Brokk-related ignores under .brokk/ and checks in an AGENTS.md style guide file.

Written by Cursor Bugbot for commit 8e6a3e6. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added the Type: Bug Issues reporting and PRs fixing problems label Feb 11, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

//
// Therefore: compute log path directly from homeDir, then call setupLogging(),
// THEN call handleLaunchArguments() which loads PathManager.
Path logPath = (homeDir != null ? homeDir : Paths.get(".")).resolve("logs");
Copy link

Choose a reason for hiding this comment

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

Log path wrong when homeDir is null

High Severity

When homeDir is null (the default for most users who don't pass --homedir), the fallback Paths.get(".") directs logs to the current working directory. Previously, setupLogging obtained the log path from PathManager.getInstance().getLogPath() after handleLaunchArguments() had called useDefaultHomePath(), which resolves to a platform-specific directory (e.g., ~/.local/share/terasology/logs on Linux). The new code cannot replicate that logic without loading PathManager, so it silently writes logs to the wrong location for the common no---homedir case.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

Good bot! I had wondered about this. Would you recommend a fix or is this a tricky case?

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

Labels

Type: Bug Issues reporting and PRs fixing problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant