Skip to content

Unified Logger - Attempt #1#777

Open
mrdeadlocked wants to merge 4 commits into
d4lfteam:mainfrom
mrdeadlocked:AIOLogger
Open

Unified Logger - Attempt #1#777
mrdeadlocked wants to merge 4 commits into
d4lfteam:mainfrom
mrdeadlocked:AIOLogger

Conversation

@mrdeadlocked

Copy link
Copy Markdown
Contributor
  1. The Unified Logging Stream
    We eliminated the dual-handler approach where the "Dashboard" and "Full Logs" were treated as separate entities with different formatting rules.
  • Single Handler: Both tabs now subscribe to a single QtConsoleHandler (aliased as console_handler in UnifiedMainWindow).
  • Visual Consistency: Both tabs now use the ANSIConsoleWidget, ensuring that the same colors and formatting options apply across the entire UI.
  • Resource Efficiency: By removing the QtActivityHandler and ThreadNameFilter, we reduced the overhead of processing every log message twice.
  1. Metadata-Driven Formatting
    We introduced two new boolean fields to the AdvancedOptionsModel: log_timestamp and technical_log_info.
  • The "Junk" Filter: When technical_log_info is disabled, the system now strips the thread name, log level (INFO/DEBUG), and the source module/line number from the UI.
  • Conditional Construction: The create_formatter function in [logger.py] was refactored to dynamically build the format string using a list-join pattern. This ensures no trailing pipes (|) appear when fields are toggled off.
  1. Decoupling UI from Diagnostics
    A critical change was made to ensure that "cleaning up" the logs for the user didn't destroy the ability to debug issues later.
  • The File Log (D4LF_FILE): This handler is now entirely independent of user settings. It is hardcoded to DEBUG level and always includes full technical metadata and timestamps.
  • The UI Log (QT_CONSOLE): This handler respects the user's log_lvl, log_timestamp, and technical_log_info settings.
  1. Visual Readability & Cleanup
  • Dark Mode Optimization: The DEBUG level color was changed from standard Blue to LIGHTCYAN_EX. Standard Blue is notoriously difficult to read against black backgrounds (like the ANSIConsoleWidget or modern terminals).
  • Banner Normalization: We removed the hardcoded print and manual string manipulation for the startup banner. The application now uses LOGGER.info to emit the version and hotkey information, allowing the unified handler to capture it naturally without "workaround" logic in [unified_window.py]
    • .1. The Unified-Logging Stream
  • We eliminated the dual-handler approach where the "Dashboard" and "Full Logs" were treated as separate entities with different formatting rules.
  • Single Handler: Both tabs now subscribe to a single QtConsoleHandler (aliased as console_handler in UnifiedMainWindow).
  • Visual Consistency: Both tabs now use the ANSIConsoleWidget, ensuring that the same colors and formatting options apply across the entire UI.
  • Resource Efficiency: By removing the QtActivityHandler and ThreadNameFilter, we reduced the overhead of processing every log message twice.
  1. Metadata-Driven Formatting
    We introduced two new boolean fields to the AdvancedOptionsModel: log_timestamp and technical_log_info.
  • The "Junk" Filter: When technical_log_info is disabled, the system now strips the thread name, log level (INFO/DEBUG), and the source module/line number from the UI.
  • Conditional Construction: The create_formatter function in [logger.py] was refactored to dynamically build the format string using a list-join pattern. This ensures no trailing pipes (|) appear when fields are toggled off.
  1. Decoupling UI from Diagnostics
    A critical change was made to ensure that "cleaning up" the logs for the user didn't destroy the ability to debug issues later.
  • The File Log (D4LF_FILE): This handler is now entirely independent of user settings. It is hardcoded to DEBUG level and always includes full technical metadata and timestamps.
  • The UI Log (QT_CONSOLE): This handler respects the user's log_lvl, log_timestamp, and technical_log_info settings.
  1. Visual Readability & Cleanup
  • Dark Mode Optimization: The DEBUG level color was changed from standard Blue to LIGHTCYAN_EX. Standard Blue is notoriously difficult to read against black backgrounds (like the ANSIConsoleWidget or modern terminals).
  • Banner Normalization: We removed the hardcoded print and manual string manipulation for the startup banner. The application now uses LOGGER.info to emit the version and hotkey information, allowing the unified handler to capture it naturally without "workaround" logic in [unified_window.py].Dark Mode Optimization: The DEBUG level color was changed from standard Blue to LIGHTCYAN_EX. Standard Blue is notoriously difficult to read against black backgrounds (like the ANSIConsoleWidget or modern terminals).
    Banner Normalization: We removed the hardcoded print and manual string manipulation for the startup banner. The application now uses LOGGER.info to emit the version and hotkey information, allowing the unified handler to capture it naturally without "workaround" logic in [unified_window.py].

self.setReadOnly(True)
self.setStyleSheet("background-color: black; color: white; font-family: Consolas, monospace; font-size: 12px;")

def append_ansi_text(self, text: str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

QPlainTextEdit does not support appendHtml(), so this will raise at the first log message. Either subclass QTextEdit here or append plain text after stripping the ANSI codes.

Comment thread src/gui/unified_window.py
@@ -245,10 +163,10 @@ def _setup_ui(self):
self.tabs.addTab(self.console_output, "Full Logs")
self._setup_tab_corner_widgets()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The startup banner/direct emit was removed, so the console tab now misses the initial banner and any logs emitted before _setup_ui() finishes. If that output still matters, replay it into the new handler or keep the direct emit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My hope is that all the emits can be dropped directly. If we're writing straight to the logger I don't get why we'd need them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's honestly possible I need some things explained to me and maybe they are required

@cjshrader cjshrader left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few small comments but overall this change looks fine. I do need to do some testing. I think you need to make sure you test the console only version and it still works fine.

)
check_chest_tabs: list[int] = Field(
default=[0, 1],
default=[0, 1, 2, 3, 4, 5, 6],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
default=[0, 1, 2, 3, 4, 5, 6],
default=[0, 1],

Comment thread src/gui/unified_window.py
@@ -245,10 +163,10 @@ def _setup_ui(self):
self.tabs.addTab(self.console_output, "Full Logs")
self._setup_tab_corner_widgets()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My hope is that all the emits can be dropped directly. If we're writing straight to the logger I don't get why we'd need them.

Comment thread src/gui/unified_window.py
@@ -245,10 +163,10 @@ def _setup_ui(self):
self.tabs.addTab(self.console_output, "Full Logs")
self._setup_tab_corner_widgets()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's honestly possible I need some things explained to me and maybe they are required

Comment thread src/main.py
print(table)
print() # blank line, just like OG D4LF
# --- END HEADER ---
for line in str(table).split("\n"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Am I missing something here? It seems to me like all of the rows have been removed. People play in console-only mode which doesn't have the GUI so at a minimum they'll need this information.

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.

3 participants