-
-
Notifications
You must be signed in to change notification settings - Fork 451
Replace Zend_Log with monolog
#5126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 replaces the deprecated Zend_Log library with Monolog (version 3.9), modernizing the logging infrastructure of OpenMage. The migration includes updating log level constants from Zend_Log integer constants to Monolog Level enums, adding Rector rules to assist with migrating custom code, and updating all internal logging calls throughout the codebase.
Key Changes:
- Replaced Zend_Log with Monolog 3.9 library and updated all logging calls to use Monolog\Level enum constants
- Added database upgrade script to migrate existing log level configuration values from Zend to Monolog format
- Configured Rector rules to automate migration of Zend_Log constants in custom code
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| composer.json | Added monolog/monolog ^3.9 dependency |
| composer.lock | Added monolog/monolog 3.9.0 and moved psr/log to packages section |
| app/Mage.php | Refactored log() function to use Monolog Logger and StreamHandler; added context parameter support |
| app/code/core/Mage/Core/Model/Logger.php | Updated log() wrapper to pass context array parameter |
| app/code/core/Mage/Core/Helper/Data.php | Added XML_PATH_DEV_LOG_* constants for log configuration paths |
| app/code/core/Mage/Core/etc/config.xml | Updated log writer model and default max_level value for Monolog compatibility |
| app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php | Database upgrade script to convert Zend log levels to Monolog levels |
| app/code/core/Mage/Core/functions.php | Updated mageCoreErrorHandler to use Level::Error |
| app/code/core/Mage/Core/Block/Template.php | Replaced Zend_Log::CRIT with Level::Critical |
| app/code/core/Mage/Core/Model/Design/Package.php | Replaced Zend_Log::ERR with Level::Error |
| app/code/core/Mage/Core/Model/Config.php | Replaced Zend_Log::NOTICE with Level::Notice |
| app/code/core/Mage/Core/Controller/Varien/Router/Admin.php | Replaced Zend_Log::ERR with Level::Error |
| app/code/core/Mage/Api/Model/Server/Handler/Abstract.php | Replaced Zend_Log::ERR with Level::Error |
| app/code/core/Mage/Adminhtml/Model/System/Config/Source/Log/Level.php | Replaced all Zend_Log constants with Level enum values |
| app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php | Replaced Zend_Log::WARN with Level::Warning |
| app/code/core/Mage/GoogleAnalytics/Helper/Data.php | Replaced Zend_Log::DEBUG with Level::Debug |
| app/code/core/Mage/Log/Helper/Data.php | Added @var documentation for $_allowedFileExtensions property |
| app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php | Replaced Zend_Log::WARN with Level::Warning |
| .rector.php | Added RenameClassConstFetchRector rules for migrating Zend_Log constants to Monolog Level |
| tests/unit/Mage/Rule/Model/AbstractTest.php | Formatting: added blank line between use statements |
| tests/unit/Mage/Core/Model/LayoutTest.php | Formatting: added blank line between use statements |
| tests/unit/Mage/Core/Model/AppTest.php | Formatting: added blank line between use statements |
| tests/unit/Mage/Catalog/Model/UrlTest.php | Formatting: added blank lines between use statements |
| tests/unit/Mage/Catalog/Model/ProductTest.php | Formatting: added blank line between use statements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 7 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
app/Mage.php:913
- Critical bug: The log level comparison logic is inverted for Monolog. In Zend_Log, lower numbers indicated higher severity (EMERG=0, DEBUG=7), so the check
$level > $maxLogLevelwould filter out less severe logs. In Monolog, higher numbers indicate higher severity (Emergency=600, Debug=100), so this check now filters out MORE severe logs instead of less severe ones. The comparison should be changed to$levelValue < $maxLogLevelto correctly filter out logs below the configured threshold.
if (!self::$_isDeveloperMode && $levelValue > $maxLogLevel && !$forceLog) {
|
# Conflicts: # .rector.php # composer.lock
|
Merged after tests. |
|
I was thinking if we should add But I could add a small helper/model class that does connect PsrLog to MageLog. |



Description (*)
Replaces Zend_Log with monolog (https://github.com/Seldaek/monolog).
Added rector rules, so you can rector on your custom code, to replace Zend_Log constants.