Skip to content

Conversation

@mdevolde
Copy link
Collaborator

feat: added loggers and logs, added logging conf for CL, moving error messages in var before raise

Why the pull request was made

Added logging specific to the library, without requiring any configuration by the user.

Summary of changes

  • Added loggers
  • Added logs
  • Removed setLevel for logging
  • Added a logging conf for the command line
  • Moved exceptions messages in vars (to avoid duplication during traceback printing)
  • Improved error printing in command line (new param)
  • Removed useless test

Screenshots (if appropriate):

Not applicable.

How has this been tested?

Tested command line and scripts with different log levels, applied tests.

Resources

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactor / code style update (non-breaking change that improves code structure or readability)
  • Tests / CI improvement (adding or updating tests or CI configuration only)
  • Other (please describe):

Checklist

  • Followed the project's contributing guidelines.
  • Updated any relevant tests.
  • Updated any relevant documentation.
  • Added comments to your code where necessary.
  • Formatted your code, run the linters, checked types and tests.

Copy link
Contributor

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 adds comprehensive logging infrastructure to the language_tool_python library, replacing the previous DEBUG_MODE boolean flag with proper Python logging. The changes include adding loggers throughout the codebase, creating a logging configuration file for the command-line tool, and refactoring error messages to store them in variables before raising exceptions (to avoid duplication in tracebacks).

Key changes:

  • Added logging.getLogger(__name__) to all modules with a NullHandler in __init__.py for library usage
  • Created logging.toml configuration file for command-line logging with INFO level default
  • Refactored exception messages to be stored in variables before being raised
  • Replaced DEBUG_MODE print statements with proper logger calls
  • Added --verbose flag to command-line tool for DEBUG level logging

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_major_functionality.py Removed obsolete test_debug_mode() test that checked the removed DEBUG_MODE variable
pyproject.toml Added logging.toml to package data and added comment to keep version in sync
language_tool_python/utils.py Added logger, debug logs for JAR/directory discovery, and refactored error messages to variables
language_tool_python/server.py Added logger, replaced DEBUG_MODE with logging, added info/debug logs throughout, and refactored error messages to variables
language_tool_python/match.py Added logger with debug logging for 4-byte character detection and refactored error messages to variables
language_tool_python/logging.toml New logging configuration file for command-line tool with INFO level default and formatted output
language_tool_python/language_tag.py Added logger with debug logging for language tag normalization and refactored error messages to variables
language_tool_python/download_lt.py Added logger, removed setLevel call, added debug/info logs, refactored error messages, and improved log formatting
language_tool_python/config_file.py Added logger with debug logging for config encoding and refactored error messages to variables
language_tool_python/__main__.py Added logging configuration loading, verbose flag, improved exception printing, and converted to context manager usage for LanguageTool
language_tool_python/__init__.py Added logger with NullHandler for library usage
MANIFEST.in Added *.toml to recursive-include pattern to include logging configuration file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdevolde mdevolde merged commit 36f7b34 into jxmorris12:master Nov 17, 2025
8 checks passed
@mdevolde mdevolde deleted the logger branch November 17, 2025 15:41
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.

1 participant