<commit_before><?php

namespace GodsDev\Backyard;

use GodsDev\Backyard\BackyardTime;

class BackyardError {

    protected $BackyardConf = array();
    //private $PageTimestamp = null;  
    protected $BackyardTime;
    
    /**
     * 
     * @param array $backyardConfConstruct
     * @param BackyardTime $BackyardTime
     */
    public function __construct(
            array $backyardConfConstruct = array(), 
            BackyardTime $BackyardTime = null
            ) {
        $this->BackyardTime = ($BackyardTime === null)?(new BackyardTime()):$BackyardTime;        
        $this->BackyardConf = array_merge(                
                array(//default values
                    'logging_level'             => 5,       //log up to the level set here, default=5 = debug//logovat az do urovne zde uvedene: 0=unknown/default_call 1=fatal 2=error 3=warning 4=info 5=debug/default_setting 6=speed  //aby se zalogovala alespoň missing db musí být logování nejníže defaultně na 1 //1 as default for writing the missing db at least to the standard ErrorLog
                    'logging_level_name'        => array(0 => 'unknown', 1 => 'fatal', 'error', 'warning', 'info', 'debug', 'speed'),
                    'logging_file'              => '',      //soubor, do kterého má my_error_log() zapisovat
                    'logging_level_page_speed'  => 5,       //úroveň logování, do které má být zapisována rychlost vygenerování stránky
                    'error_log_message_type'    => 0,       //parameter message_type http://cz2.php.net/manual/en/function.error-log.php for my_error_log; default is 0, i.e. to send message to PHP's system logger; recommended is however 3, i.e. append to the file destination set either in field $this->BackyardConf['logging_file or in table system
                    'die_graciously_verbose'    => true,    //show details by die_graciously() on screen (it is always in the error_log); on production it is recomended to be set to to false due security
                    'mail_for_admin_enabled'    => false,   //fatal error may just be written in log //$backyardMailForAdminEnabled = "<EMAIL>";//on production, it is however recommended to set an e-mail, where to announce fatal errors
                    'log_monthly_rotation'      => true,    //true, pokud má být přípona .log.Y-m.log (výhodou je měsíční rotace); false, pokud má být jen .log (výhodou je sekvenční zápis chyb přes my_error_log a jiných PHP chyb)
                    'log_standard_output'       => false,   //true, pokud má zároveň vypisovat na obrazovku; false, pokud má vypisovat jen do logu
                    'log_profiling_step'        => false,   //110812, my_error_log neprofiluje rychlost //$PROFILING_STEP = 0.008;//110812, my_error_log profiluje čas mezi dvěma měřenými body vyšší než udaná hodnota sec
                    'error_hacked'              => true,    //ERROR_HACK parameter is reflected
                    'error_hack_from_get'       => 0,       //in this field, the value of $_GET['ERROR_HACK'] shall be set below                    
                ),
                $backyardConfConstruct);
        //@todo do not use $this->BackyardConf but set the class properties right here accordingly; and also provide means to set the values otherwise later
    }
    
/**
 * Error_log() modified to log necessary debug information by application to its own log (common to the whole host by default).
 * 
 * <b>ERROR NUMBER LIST</b><commit_msg>8 log level specific methods according to http://www.php-fig.org/psr/psr-3/<commit_after><?php

namespace GodsDev\Backyard;

use GodsDev\Backyard\BackyardTime;

class BackyardError {

    protected $BackyardConf = array();
    //private $PageTimestamp = null;  
    protected $BackyardTime;
    
    /**
     * 
     * @param array $backyardConfConstruct
     * @param BackyardTime $BackyardTime
     */
    public function __construct(
            array $backyardConfConstruct = array(), 
            BackyardTime $BackyardTime = null
            ) {
        $this->BackyardTime = ($BackyardTime === null)?(new BackyardTime()):$BackyardTime;        
        $this->BackyardConf = array_merge(                
                array(//default values
                    'logging_level'             => 5,       //log up to the level set here, default=5 = debug//logovat az do urovne zde uvedene: 0=unknown/default_call 1=fatal 2=error 3=warning 4=info 5=debug/default_setting 6=speed  //aby se zalogovala alespoň missing db musí být logování nejníže defaultně na 1 //1 as default for writing the missing db at least to the standard ErrorLog
                    'logging_level_name'        => array(0 => 'unknown', 1 => 'fatal', 'error', 'warning', 'info', 'debug', 'speed'),
                    'logging_file'              => '',      //soubor, do kterého má my_error_log() zapisovat
                    'logging_level_page_speed'  => 5,       //úroveň logování, do které má být zapisována rychlost vygenerování stránky
                    'error_log_message_type'    => 0,       //parameter message_type http://cz2.php.net/manual/en/function.error-log.php for my_error_log; default is 0, i.e. to send message to PHP's system logger; recommended is however 3, i.e. append to the file destination set either in field $this->BackyardConf['logging_file or in table system
                    'die_graciously_verbose'    => true,    //show details by die_graciously() on screen (it is always in the error_log); on production it is recomended to be set to to false due security
                    'mail_for_admin_enabled'    => false,   //fatal error may just be written in log //$backyardMailForAdminEnabled = "<EMAIL>";//on production, it is however recommended to set an e-mail, where to announce fatal errors
                    'log_monthly_rotation'      => true,    //true, pokud má být přípona .log.Y-m.log (výhodou je měsíční rotace); false, pokud má být jen .log (výhodou je sekvenční zápis chyb přes my_error_log a jiných PHP chyb)
                    'log_standard_output'       => false,   //true, pokud má zároveň vypisovat na obrazovku; false, pokud má vypisovat jen do logu
                    'log_profiling_step'        => false,   //110812, my_error_log neprofiluje rychlost //$PROFILING_STEP = 0.008;//110812, my_error_log profiluje čas mezi dvěma měřenými body vyšší než udaná hodnota sec
                    'error_hacked'              => true,    //ERROR_HACK parameter is reflected
                    'error_hack_from_get'       => 0,       //in this field, the value of $_GET['ERROR_HACK'] shall be set below                    
                ),
                $backyardConfConstruct);
        //@todo do not use $this->BackyardConf but set the class properties right here accordingly; and also provide means to set the values otherwise later
    }

    /**
     * System is unusable.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function emergency($message, array $context = array()){
        return $this->log(0,$message,$context);
    }

    /**
     * Action must be taken immediately.
     *
     * Example: Entire website down, database unavailable, etc. This should
     * trigger the SMS alerts and wake you up.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function alert($message, array $context = array()){
        return $this->log(1,$message,$context);
    }

    /**
     * Critical conditions.
     *
     * Example: Application component unavailable, unexpected exception.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function critical($message, array $context = array()){
        return $this->log(1,$message,$context);
    }

    /**
     * Runtime errors that do not require immediate action but should typically
     * be logged and monitored.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function error($message, array $context = array()){
        return $this->log(2,$message,$context);
    }

    /**
     * Exceptional occurrences that are not errors.
     *
     * Example: Use of deprecated APIs, poor use of an API, undesirable things
     * that are not necessarily wrong.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function warning($message, array $context = array()){
        return $this->log(3,$message,$context);
    }

    /**
     * Normal but significant events.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function notice($message, array $context = array()){
        return $this->log(4,$message,$context);
    }

    /**
     * Interesting events.
     *
     * Example: User logs in, SQL logs.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function info($message, array $context = array()){
        return $this->log(4,$message,$context);
    }

    /**
     * Detailed debug information.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function debug($message, array $context = array()){
        return $this->log(5,$message,$context);
    }

    /**
     * Logs with an arbitrary level.
     *
     * @param mixed $level
     * @param string $message
     * @param array $context
     * @return null
     */    
/**
 * Error_log() modified to log necessary debug information by application to its own log (common to the whole host by default).
 * 
 * <b>ERROR NUMBER LIST</b>
{'fraction_non_alphanumeric': 0.09891696750902527, 'fraction_numerical': 0.008251676121712223, 'mean_word_length': 2.2867796610169493, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4312736', 'n_tokens_mistral': 2883, 'n_tokens_neox': 2775, 'n_words': 912}