Skip to content

Conversation

@sreichel
Copy link
Contributor

@sreichel sreichel commented Dec 3, 2025

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.

Copilot AI review requested due to automatic review settings December 3, 2025 19:54
@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Usa Relates to Mage_Usa Component: Eav Relates to Mage_Eav Component: Adminhtml Relates to Mage_Adminhtml Mage.php Relates to app/Mage.php Component: Api PageRelates to Mage_Api Component: Log Relates to Mage_Log Component: GoogleAnalytics Relates to Mage_GoogleAnalytics composer Relates to composer.json phpunit rector labels Dec 3, 2025
Copilot finished reviewing on behalf of sreichel December 3, 2025 19:57
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 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

@sreichel sreichel requested a review from Copilot December 3, 2025 20:35
Copilot finished reviewing on behalf of sreichel December 3, 2025 20:38
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

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

@sreichel sreichel requested a review from Copilot December 3, 2025 20:49
Copilot finished reviewing on behalf of sreichel December 3, 2025 20:53
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

Copilot reviewed 23 out of 24 changed files in this pull request and generated 7 comments.

@sreichel sreichel requested a review from Copilot December 3, 2025 21:06
Copilot finished reviewing on behalf of sreichel December 3, 2025 21:10
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

Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.

@sreichel sreichel requested a review from Copilot December 3, 2025 21:15
Copilot finished reviewing on behalf of sreichel December 3, 2025 21:19
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

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 > $maxLogLevel would 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 < $maxLogLevel to correctly filter out logs below the configured threshold.
        if (!self::$_isDeveloperMode && $levelValue > $maxLogLevel && !$forceLog) {

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 3, 2025

@github-actions github-actions bot removed the phpunit label Dec 3, 2025
# Conflicts:
#	.rector.php
#	composer.lock
@sreichel
Copy link
Contributor Author

sreichel commented Dec 3, 2025

Merged after tests.

@sreichel sreichel merged commit cea4be1 into OpenMage:main Dec 3, 2025
22 checks passed
@sreichel sreichel deleted the zend/log branch December 3, 2025 23:24
@sreichel sreichel changed the title Replece Zend_Log with monolog Replace Zend_Log with monolog Dec 4, 2025
@Hanmac
Copy link
Contributor

Hanmac commented Dec 4, 2025

I was thinking if we should add psr/log too, but that doesn't support filenames.

But I could add a small helper/model class that does connect PsrLog to MageLog.
(using null filename and let it fall back to default)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Adminhtml Relates to Mage_Adminhtml Component: Api PageRelates to Mage_Api Component: Core Relates to Mage_Core Component: Eav Relates to Mage_Eav Component: GoogleAnalytics Relates to Mage_GoogleAnalytics Component: Log Relates to Mage_Log Component: Usa Relates to Mage_Usa composer Relates to composer.json improvement Mage.php Relates to app/Mage.php rector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants