Logger::init PHP Method

init() public method

public init ( )
    public function init()
    {
        parent::init();
        $this->debug_log = session_id() ? $this->recall('debug_log', '') : '';
        if (session_id()) {
            $this->forget('debug_log');
        }
        $this->debug_log .= '[<font color=red>Debug log from ' . date('d.m.Y H:m:s') . ' to ' . $_SERVER['QUERY_STRING'] . "</font>] - debug started<br>\n";
        $this->debug_added = false;
        register_shutdown_function(array($this, 'showDebugInfo'));
        $this->log_output = $this->app->getConfig('logger/log_output', null);
        $this->web_output = $this->app->getConfig('logger/web_output', 'full');
        if (!$this->web_output) {
            $this->public_error_message = $this->app->getConfig('debug_public_error_message', 'We were unable to deal with your request. Please retry later.');
        }
        $this->log_dir = $this->app->getConfig('logger/log_dir', '/var/log/atk4/' . $this->app->name);
        if ($this->log_output) {
            $this->openLogFile('error');
            $this->openLogFile('debug');
            $this->openLogFile('info');
            if (rand(1, 50) == 1) {
                $this->cleanupLogDirectory();
            }
        }
        if ($this->log_output == 'full' || $this->web_output == 'full') {
            // Full logging will require some preparations
            $this->gatherDetails();
        }
        if ($this->app instanceof App_Web) {
            $this->html_stdout = true;
        }
        $this->app->addHook('caught-exception', array($this, 'caughtException'));
        $this->app->addHook('output-fatal', array($this, 'outputFatal'));
        $this->app->addHook('output-warning', array($this, 'outputWarning'));
        $this->app->addHook('output-info', array($this, 'outputInfo'));
        $this->app->addHook('output-debug', array($this, 'outputDebug'));
        $this->app->debug('Logger is initialized');
    }

Usage Example

Example #1
0
 static function init()
 {
     $version_file = APP_PATH . '/../version';
     if (file_exists($version_file)) {
         self::$version = trim(@file_get_contents($version_file));
     }
     $config_file = APP_PATH . '/config/config.php';
     if (!file_exists($config_file)) {
         throw new Exception("No config file");
     }
     $config = (include $config_file);
     self::$config = $config;
     self::$env = $config['env'];
     #self::$context = new stdClass();
     self::$context = new Context();
     Logger::init($config['logger']);
     if (isset($config['db'])) {
         Db::init($config['db']);
     }
     if (get_magic_quotes_gpc()) {
         foreach ($_GET as $k => $v) {
             $_GET[$k] = Text::stripslashes($v);
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = Text::stripslashes($v);
         }
         foreach ($_COOKIE as $k => $v) {
             $_COOKIE[$k] = Text::stripslashes($v);
         }
     }
     $_REQUEST = $_GET + $_POST + $_COOKIE;
 }
All Usage Examples Of Logger::init