Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a significant refactor to the project's logging strategy. It replaces direct usage of the custom
printeoutput utility with Python's standardloggingmodule across the codebase, and adds a newlogging_config.pymodule 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:
logging_config.pymodule that configures colored logging output usingcolorlog, provides utilities for formatting colored text in log messages, and sets up project-wide logging configuration.printe.output,printe.error, and similar functions with appropriatelogger.info,logger.error,logger.warning,logger.critical, orlogger.debugcalls in modules such aspymysql_bot.py,ask_bot.py,except_err.py,bot_edit_by_time.py,txtlib.py,user_agent.py,wd_sparql.py,all_apis.py, andbot.py. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]except_err.pyto use the logging module for all output, including warnings and tracebacks.Code formatting and function signature improvements:
ask_bot.py,printe.py, andwd_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.