Skip to content

Conversation

@18c83fd3-25ea-4ed9-8205-2abeff9b3883

I've fixed the issue where setting color = false in joinmarket.cfg only disabled colored output for log messages but not for other console output.

The fix involved three changes to src/jmbase/support.py:

Added a global variable to track the color setting:

  • Global variable to track whether colored output is enabled
    colored_output = [True]

  • Modified the jmprint() function to respect this setting:

if sys.stdout.isatty() and colored_output[0]:
print(jm_colorizer.colorize_message(fmtd_msg))
else:
print(fmtd_msg)

  • Updated the set_logging_color() function to set this global variable:

def set_logging_color(colored=False):
# Update the global colored_output setting
colored_output[0] = colored
if colored and sys.stdout.isatty():
handler.colorizer = jm_colorizer
else:
handler.colorizer = MonochromaticColorizer()

Now when a user sets color = false in joinmarket.cfg, it will disable colored output for both log messages and direct console output via jmprint().

@18c83fd3-25ea-4ed9-8205-2abeff9b3883

?

@kristapsk kristapsk requested a review from Copilot July 5, 2025 12:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that the color = false setting in joinmarket.cfg now fully disables colored output for both log messages and direct console prints via jmprint().

  • Introduces a global flag to track color output
  • Updates jmprint() to respect the color flag
  • Modifies set_logging_color() to update the new flag
Comments suppressed due to low confidence (2)

src/jmbase/support.py:202

  • The new colored_output flag and its effect on jmprint() should be documented in a module or function docstring so users understand how set_logging_color influences both logging and direct prints.
def set_logging_color(colored=False):

src/jmbase/support.py:187

  • Add unit tests for jmprint to verify behavior with colored_output toggled on and off, and in both TTY and non-TTY environments to prevent regressions.
    if sys.stdout.isatty() and colored_output[0]:

core_alert = ['']
debug_silence = [False]
# Global variable to track whether colored output is enabled
colored_output = [True]
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using a simple boolean global (e.g., colored_output_enabled: bool) with a global declaration in set_logging_color instead of a single-element list, which can be confusing for future maintainers.

Suggested change
colored_output = [True]
colored_output_enabled = True

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@roshii roshii left a comment

Choose a reason for hiding this comment

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

Some tweaks are needed imo.

.qt_for_python/
cmtdata/
**/build/
test_venv/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed imo

core_alert = ['']
debug_silence = [False]
# Global variable to track whether colored output is enabled
colored_output = [True]
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple boolean is best suited imo

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