You can define an array of constant as a key value and assign boolean as its value (TRUE/FALSE). By filtering array on its boolean value you can then sum value of all keys to create a unique value which will represent your error level.

// https://www.php.net/manual/en/errorfunc.constants.php
$errorsActive = [
    E_ERROR             => FALSE,
    E_WARNING           => FALSE,
    E_PARSE             => FALSE,
    E_NOTICE            => FALSE,
    E_CORE_ERROR        => FALSE,
    E_CORE_WARNING      => FALSE,
    E_COMPILE_ERROR     => FALSE,
    E_COMPILE_WARNING   => FALSE,
    E_USER_ERROR        => FALSE,
    E_USER_WARNING      => FALSE,
    E_USER_NOTICE       => FALSE,
    E_STRICT            => FALSE,
    E_RECOVERABLE_ERROR => FALSE,
    E_DEPRECATED        => FALSE,
    E_USER_DEPRECATED   => FALSE,
    E_ALL               => FALSE,
];

$errorSumLvl = array_sum( array_keys( $errorsActive, $search = TRUE ) );
$errorSumLvl = ($errorSumLvl === 0) ? -1 : $errorSumLvl;
$errorSumLvl = ($errorSumLvl > E_ALL) ? E_ALL : $errorSumLvl;

if($errorSumLvl <= 0){
	ini_set('display_errors', '0');
	ini_set('error_reporting', $errorSumLvl );
        ini_set('log_errors', '1');
	error_reporting($errorSumLvl);
}else {
	ini_set('display_errors','On'); // < change if needed
	ini_set('error_reporting', $errorSumLvl );
        ini_set('log_errors', '1');
	error_reporting($errorSumLvl);
}

The code above based on the array value will disable or enable errors

In wordpress you would instead set:

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true ); // ini_set('log_errors', '1');
// -- or -- define own path to log file
define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', '0' );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

If you would like to disable error reporting set those values to false.

https://wordpress.org/support/article/debugging-in-wordpress/
https://www.php.net/manual/en/errorfunc.constants.php

0
Would love your thoughts, please comment.x
()
x