Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,27 @@ jobs:
run: composer test:coverage

- name: Upload coverage to Codecov
if: matrix.php == '8.4' && secrets.CODECOV_TOKEN != ''
if: matrix.php == '8.4'
continue-on-error: true
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
fail_ci_if_error: false

# Alternative
- name: Upload coverage to Qlty
if: matrix.php == '8.4' && secrets.QLTY_TOKEN != ''
if: matrix.php == '8.4'
continue-on-error: true
uses: qltysh/qlty-action/coverage@v2
with:
token: ${{ secrets.QLTY_TOKEN }}
files: ./coverage.xml
continue-on-error: true

# Alternative
#- name: Upload coverage to Scrutinizer
# if: matrix.php == '8.4' && secrets.SCRUTINIZER_ACCESS_TOKEN != ''
# if: matrix.php == '8.4'
# continue-on-error: true
# uses: scrutinizer-ci/ocular@v1
# with:
# access-token: ${{ secrets.SCRUTINIZER_ACCESS_TOKEN }}
Expand Down Expand Up @@ -163,7 +165,6 @@ jobs:
# - Enables security-focused code review workflow
# - Creates security alerts for repository maintainers
- name: Run Snyk to check for vulnerabilities (PHP)
if: secrets.SNYK_TOKEN != ''
continue-on-error: true
uses: snyk/actions/php@e2221410bff24446ba09102212d8bc75a567237d
env:
Expand All @@ -172,7 +173,7 @@ jobs:
args: --severity-threshold=high --sarif-file-output=snyk.sarif --file=composer.lock

- name: Upload Snyk results to GitHub Code Scanning
if: hashFiles('snyk.sarif') != ''
continue-on-error: true
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ $config = [
'min_level' => 'info',

// Optional: Wonolog namespace (default: 'Inpsyde\Wonolog')
'wonolog_namespace' => 'MyApp\Wonolog',
'wonolog_namespace' => 'MyPlugin\Vendor\Wonolog',

// Optional: PSR Log namespace (default: 'Psr\Log')
// Useful for Mozart-isolated dependencies
'psr_log_namespace' => 'MyPlugin\Vendor\Psr\Log',

// Optional: WordPress constant to disable logging
// (default: auto-generated from component_name)
Expand All @@ -201,24 +205,26 @@ $config = [

```bash
# Global logger settings
LOGGER_COMPONENT_NAME=my-plugin # Plugin/Theme identifier
LOGGER_RETENTION_DAYS=30 # Log retention period
LOGGER_MIN_LEVEL=info # Minimum log level
LOGGER_DISABLED=false # Disable all logging
LOGGER_WONOLOG_NAMESPACE=Inpsyde\Wonolog
LOGGER_COMPONENT_NAME=my-plugin # Plugin/Theme identifier
LOGGER_RETENTION_DAYS=30 # Log retention period
LOGGER_MIN_LEVEL=info # Minimum log level
LOGGER_DISABLED=false # Disable all logging
LOGGER_WONOLOG_NAMESPACE=Inpsyde\Wonolog # Wonolog namespace
LOGGER_PSR_LOG_NAMESPACE=Psr\Log # PSR Log namespace

# Plugin-specific settings (higher priority)
MY_PLUGIN_LOGGER_RETENTION_DAYS=60
MY_PLUGIN_LOGGER_DISABLED=false
MY_PLUGIN_LOGGER_MIN_LEVEL=warning
MY_PLUGIN_LOGGER_DISABLED=false
MY_PLUGIN_LOGGER_PSR_LOG_NAMESPACE=MyPlugin\Vendor\Psr\Log
```

### WordPress Constants (wp-config.php)

```php
// Control logging behavior per plugin
define('MY_PLUGIN_LOGGER_DISABLED', true); // Disable all logging
define('MY_PLUGIN_LOGGER_RETENTION_DAYS', 90); // Keep logs for 90 days
define('MY_PLUGIN_LOGGER_RETENTION_DAYS', 90); // Keep logs for 90 days

// Global WordPress debug (affects fallback behavior)
define('WP_DEBUG', true); // Forces error_log() usage in fallback mode
Expand Down Expand Up @@ -530,6 +536,11 @@ add_filter('wp_logger_wonolog_namespace', function($namespace) {
return 'MyApp\Logger';
});

// Change PSR Log namespace
add_filter('wp_logger_psr_log_namespace', function($namespace) {
return 'MyPlugin\Vendor\Psr\Log';
});

// Modify Wonolog prefix
add_filter('wp_logger_wonolog_prefix', function($prefix, $level, $message, $context, $config) {
return 'myapp.log';
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"ci": "@check --no-interaction",
"lint": "@check --tasks=phpcsfixer,phplint,phpstan,rector",
"quality": "@check --tasks=phpmnd,phpparser",
"rector": "@check --tasks=rector",
"security": "@check --tasks=securitychecker_roave",
"test": "@check --tasks=phpunit",
"test:coverage": "vendor/bin/phpunit --coverage-clover=coverage.xml"
Expand Down
Loading
Loading