Rank keyed by level. Higher means more verbose. */ public static function ranks(): array { return array( self::OFF => 0, self::ERROR => 1, self::WARNING => 2, self::INFO => 3, self::DEBUG => 4, ); } /** * Returns the labels for the settings screen. * * @return array Translated labels keyed by level. */ public static function choices(): array { return array( self::OFF => __( 'Off', 'devplugins-custom-form-builder' ), self::ERROR => __( 'Errors only', 'devplugins-custom-form-builder' ), self::WARNING => __( 'Errors and warnings', 'devplugins-custom-form-builder' ), self::INFO => __( 'Errors, warnings and activity', 'devplugins-custom-form-builder' ), self::DEBUG => __( 'Everything (debug)', 'devplugins-custom-form-builder' ), ); } /** * Determines whether a line is severe enough to be written. * * @param string $level Level of the line. * @param string $threshold Level the site has asked for. * * @return bool True when the line should be kept. */ public static function allows( string $level, string $threshold ): bool { $ranks = self::ranks(); $line = $ranks[ $level ] ?? $ranks[ self::ERROR ]; $limit = $ranks[ $threshold ] ?? $ranks[ self::OFF ]; return $limit > 0 && $line <= $limit; } }