Skip to content

feat: Added configuration options for error levels - #394

Merged
norkunas merged 1 commit into
geocoder-php:masterfrom
Chris53897:feature/log-level
Jan 5, 2026
Merged

feat: Added configuration options for error levels#394
norkunas merged 1 commit into
geocoder-php:masterfrom
Chris53897:feature/log-level

Conversation

@Chris53897

@Chris53897 Chris53897 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

#366

Summary by CodeRabbit

  • New Features

    • Introduced optional log level configuration options for geocode and reverse geocoding queries. Users can now independently adjust logging verbosity for these specific operations through configuration settings.
  • Documentation

    • Updated configuration schema documentation to reflect the new optional log level settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 23, 2025

Copy link
Copy Markdown

Walkthrough

The chaining factory has been updated to support two new optional configuration keys—geocode_log_level and reverse_log_level—that allow setting query-specific log levels when a logger is configured.

Changes

Cohort / File(s) Summary
ChainFactory Log Level Configuration
src/ProviderFactory/ChainFactory.php
Added support for optional geocode_log_level and reverse_log_level config keys. When a logger is present, these values are conditionally applied via setGeocodeQueryLogLevel() and setReverseQueryLogLevel() setters. Provider configuration schema extended to document the new optional string|null keys. Updated getProvider() docblock to reflect expanded config structure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Added configuration options for error levels' is misleading. The actual changes add log level configuration options (geocode_log_level and reverse_log_level), not error level options. Revise the title to accurately reflect the changes, such as 'feat: Add configuration options for log levels' or 'feat: Add geocode and reverse query log level configuration'.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/ProviderFactory/ChainFactory.php (1)

41-46: Consider validating log level values against PSR-3 standards.

The configuration accepts any string value for log levels, which could lead to runtime errors if invalid values are provided. Consider adding validation to restrict values to valid PSR-3 log levels: emergency, alert, critical, error, warning, notice, info, debug.

🔎 Proposed validation in configureOptionResolver
 $resolver->setDefault('geocode_log_level', null);
 $resolver->setAllowedTypes('geocode_log_level', ['string', 'null']);
+$resolver->setAllowedValues('geocode_log_level', function ($value) {
+    return $value === null || in_array($value, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'], true);
+});

 $resolver->setDefault('reverse_log_level', null);
 $resolver->setAllowedTypes('reverse_log_level', ['string', 'null']);
+$resolver->setAllowedValues('reverse_log_level', function ($value) {
+    return $value === null || in_array($value, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'], true);
+});
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b42484 and ddc3c80.

📒 Files selected for processing (1)
  • src/ProviderFactory/ChainFactory.php
🧰 Additional context used
🧬 Code graph analysis (1)
src/ProviderFactory/ChainFactory.php (2)
src/ProviderFactory/AbstractFactory.php (1)
  • getProvider (41-41)
src/ProviderFactory/HostIpFactory.php (1)
  • getProvider (30-35)
🔇 Additional comments (3)
src/ProviderFactory/ChainFactory.php (3)

33-33: LGTM: Docblock accurately reflects the new configuration options.

The updated docblock correctly documents the new optional parameters with appropriate types.


59-60: Configuration option looks good structurally.

The default and type configuration are appropriate. See the previous comment for a recommendation to add value validation.


62-63: Configuration option looks good structurally.

The default and type configuration are appropriate. See the previous comment for a recommendation to add value validation.

Comment on lines +40 to +46

if (isset($config['geocode_log_level'])) {
$provider->setGeocodeQueryLogLevel($config['geocode_log_level']);
}
if (isset($config['reverse_log_level'])) {
$provider->setReverseQueryLogLevel($config['reverse_log_level']);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, locate the file and check its context
if [ -f "src/ProviderFactory/ChainFactory.php" ]; then
  echo "=== File found, showing lines 30-55 for context ==="
  sed -n '30,55p' src/ProviderFactory/ChainFactory.php
else
  echo "File not found at src/ProviderFactory/ChainFactory.php"
fi

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 967


🏁 Script executed:

# Check composer.json for the geocoder-php/chain-provider version
if [ -f "composer.json" ]; then
  echo "=== composer.json content ==="
  cat composer.json | jq '.require, .["require-dev"]' 2>/dev/null || grep -A5 -B5 "chain-provider" composer.json
fi

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 2228


🏁 Script executed:

# Search for Chain provider class and method definitions in the codebase
echo "=== Searching for Chain class definition ==="
rg "class Chain" --type php -A 20 | head -50

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 2878


🏁 Script executed:

# Look for method definitions related to log levels
echo "=== Searching for setGeocodeQueryLogLevel and setReverseQueryLogLevel ==="
rg "setGeocodeQueryLogLevel|setReverseQueryLogLevel" --type php

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 389


🌐 Web query:

geocoder-php/chain-provider github releases v4.5.0

💡 Result:

Do you want a link to the GitHub release page for geocoder-php/chain-provider v4.5.0, or just confirmation whether that tag/release exists?


🌐 Web query:

geocoder-php/chain-provider Chain class setGeocodeQueryLogLevel setReverseQueryLogLevel

💡 Result:

Short answer: The Chain provider does not define setGeocodeQueryLogLevel or setReverseQueryLogLevel. The official Chain provider only composes/iterates providers — it has no per-query log-level setters in its API. [1][2]

If you need to control logging per-query:

  • Configure a PSR-3 logger on each underlying provider (or wrap providers) and control levels there.
  • Or wrap the Chain provider with your own decorator that adjusts logging around geocodeQuery()/reverseQuery() calls.

Sources:

  • Chain provider docs (describes Chain behavior, no log-level API). [1]
  • Geocoder GitHub repository / docs (API overview; Chain is a provider that iterates providers). [2]

🏁 Script executed:

# Check if we can find more info about the Chain provider package
# Look for any vendor files or composer.lock that might help
if [ -f "composer.lock" ]; then
  echo "=== Looking for chain-provider in composer.lock ==="
  jq '.packages[] | select(.name == "geocoder-php/chain-provider") | {name, version, description}' composer.lock 2>/dev/null || grep -A 10 "chain-provider" composer.lock | head -20
fi

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 60


🏁 Script executed:

# Search for Provider class definition and its methods
echo "=== Searching for Provider class methods ==="
rg "class Provider|function setGeocodeQueryLogLevel|function setReverseQueryLogLevel" --type php | head -30

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 218


🌐 Web query:

Chain provider geocoder-php github.com willdurand/geocoder-php/chain-provider

💡 Result:

The chain provider (package geocoder-php/chain-provider) is a special Geocoder provider that takes a list/array of providers and iterates them in order, stopping when one returns a result. It’s provided in the Geocoder PHP project; example usage and docs are on the project site and GitHub. [1][2]

Sources:
[1] geocoder-php/Geocoder (GitHub) — Chain provider description.
[2] Geocoder PHP documentation — “The Chain Provider” (geocoder-php.org).


🏁 Script executed:

# Look at the directory structure to see if there are vendor files
echo "=== Checking directory structure for vendor or composer files ==="
ls -la | grep -E "(composer|vendor)"

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 207


🌐 Web query:

site:github.com willdurand geocoder-php chain-provider Chain.php setGeocodeQueryLogLevel

💡 Result:

I searched the geocoder-php repositories and could not find any method named setGeocodeQueryLogLevel on the Chain provider (or a Chain.php defining that method). The Chain provider is documented as geocoder-php/chain-provider and used by the main Geocoder project and integrations (e.g. GeocoderLaravel). [1][2]

Sources:

  • Geocoder (main repo) — docs mention the Chain provider. [1]
  • GeocoderLaravel — default config uses the Chain provider. [2]

If you want, tell me the repository/path where you expect that method (or paste the file) and I’ll look for it more precisely.


🏁 Script executed:

# Try to find composer.lock and check the actual chain-provider version installed
if [ -f "composer.lock" ]; then
  echo "=== Chain provider version in composer.lock ==="
  python3 << 'PYEOF'
import json
try:
  with open('composer.lock', 'r') as f:
    data = json.load(f)
    for pkg in data.get('packages', []) + data.get('packages-dev', []):
      if pkg.get('name') == 'geocoder-php/chain-provider':
        print(f"Package: {pkg['name']}")
        print(f"Version: {pkg.get('version', 'N/A')}")
        print(f"Source: {pkg.get('source', {}).get('url', 'N/A')}")
except Exception as e:
  print(f"Error: {e}")
PYEOF
fi

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 164


🏁 Script executed:

# Check the test file to see what it actually tests
echo "=== Checking ProviderFactoryTest for Chain-related tests ==="
grep -A 20 -B 5 "ChainFactory\|setGeocodeQueryLogLevel\|setReverseQueryLogLevel" tests/Functional/ProviderFactoryTest.php 2>/dev/null || echo "Pattern not found in test file"

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 169


🏁 Script executed:

# Let's also check what methods Chain provider actually has by searching comments/docs
echo "=== Looking for any documentation or configuration related to Chain logging ==="
rg "Chain|geocode_log_level|reverse_log_level" --type php -B 2 -A 2 src/ | head -60

Repository: geocoder-php/BazingaGeocoderBundle

Length of output: 3384


Remove the calls to non-existent methods on the Chain provider.

The setGeocodeQueryLogLevel() and setReverseQueryLogLevel() methods do not exist in the Chain provider API (geocoder-php/chain-provider v4.5.x). These method calls at lines 43-46 will cause a runtime error: "Call to undefined method". The Chain provider only iterates through child providers—it has no per-query log-level setter methods. Either remove this code or configure logging on individual child providers instead.

🤖 Prompt for AI Agents
In src/ProviderFactory/ChainFactory.php around lines 40 to 46, the code calls
setGeocodeQueryLogLevel() and setReverseQueryLogLevel() on the Chain provider
which do not exist and will throw "Call to undefined method"; remove those two
method calls from the Chain provider setup and, if per-query log levels are
required, iterate over the configured child providers and set their
geocode/reverse log levels individually (or apply logging configuration when
each child provider is created) instead.
@norkunas

Copy link
Copy Markdown
Member

You could cherry-pick commit from that PR to give the credit also to the author 😊

@Chris53897

Copy link
Copy Markdown
Contributor Author

I am not sure how to do this.
Can try tomorrow or just a credit in the release notes.
I personally do not care about credit. Just gettings things done.
But of course i understand this.

@norkunas

norkunas commented Dec 23, 2025

Copy link
Copy Markdown
Member

git cherry-pick commit-hash
You just have to add authors remote to your git of this project otherwise it will not find it

@norkunas
norkunas merged commit 7474234 into geocoder-php:master Jan 5, 2026
18 checks passed
@Chris53897
Chris53897 deleted the feature/log-level branch January 5, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants