Skip to content

Replace printe with logging and add logging_config#133

Merged
MrIbrahem merged 5 commits intomainfrom
update
Feb 17, 2026
Merged

Replace printe with logging and add logging_config#133
MrIbrahem merged 5 commits intomainfrom
update

Conversation

@MrIbrahem
Copy link
Collaborator

This pull request introduces a significant refactor to the project's logging strategy. It replaces direct usage of the custom printe output utility with Python's standard logging module across the codebase, and adds a new logging_config.py module to provide colored log output. This change standardizes logging, improves maintainability, and enables better control over log formatting and levels. Additionally, some minor code formatting improvements and function signature adjustments were made for clarity.

Logging refactor and standardization:

  • Introduced a new logging_config.py module that configures colored logging output using colorlog, provides utilities for formatting colored text in log messages, and sets up project-wide logging configuration.
  • Replaced all calls to printe.output, printe.error, and similar functions with appropriate logger.info, logger.error, logger.warning, logger.critical, or logger.debug calls in modules such as pymysql_bot.py, ask_bot.py, except_err.py, bot_edit_by_time.py, txtlib.py, user_agent.py, wd_sparql.py, all_apis.py, and bot.py. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
  • Updated the custom exception handler in except_err.py to use the logging module for all output, including warnings and tracebacks.

Code formatting and function signature improvements:

  • Reformatted several function signatures and argument lists for better readability, particularly in ask_bot.py, printe.py, and wd_sparql.py. [1] [2] [3] [4] [5]

These changes modernize the codebase's approach to logging, making it easier to manage log output and integrate with other tools.Replace ad-hoc printe prints and direct prints with Python logging across the codebase and add a new logging_config.py to provide a colorized logging formatter. Exception handling now uses logger.exception / logger.warning / logger.error instead of exception_err/printe where appropriate. Also added logger instances and logging imports in many modules, adjusted some function signatures/formatting for readability, and improved error logging for pymysql and SPARQL code paths. This centralizes output control and enables configurable, colored logs.

Replace ad-hoc printe prints and direct prints with Python logging across the codebase and add a new logging_config.py to provide a colorized logging formatter. Exception handling now uses logger.exception / logger.warning / logger.error instead of exception_err/printe where appropriate. Also added logger instances and logging imports in many modules, adjusted some function signatures/formatting for readability, and improved error logging for pymysql and SPARQL code paths. This centralizes output control and enables configurable, colored logs.
Introduce module loggers and switch from various custom prints/log helpers to the standard logging API. Added logging.getLogger(__name__) and replaced log/log_one/printe calls with logger.* in newapi/super/mwclient/client.py, newapi/super/S_Page/super_page.py, newapi/api_utils/bot_edit/bot_edit_by_time.py, and z_te_sts/test_bot_api.py. Removed unused imports and deleted z_te_sts/test_ncc_page.py. Also added colorlog to requirements.in to support enhanced logging formatting.
Move showDiff implementation from printe to newapi/api_utils/ask_bot.py and use difflib for unified diffs; remove redundant printe code and unused imports across utility modules. Add logging-based diff output and adjust calls to use the new showDiff. Add type hint and docstring to MainPage.page_links and annotate its returned data. Silence noisy error logs by only logging when result is not in good_result in bot and bot_new, and rename all_usprops to _all_usprops. Misc cleanup: remove stale comments and unused imports.
@MrIbrahem MrIbrahem merged commit 4e73de7 into main Feb 17, 2026
1 check passed
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