Comments out the default log initialization code.

@param string $global_php the Laravel 'app/start/global.php' file path.
489888
protected function commentOutDefaultLogInit($global_php)
    {
        $find = "Log::useFiles(storage_path().'/logs/laravel.log');";
        $replace = "/* Log initialization moved to 'app/start/local.php' and 'app/start/production.php' files. */";

        $contents = file_get_contents($global_php);

        $modified = str_replace($find, $replace, $contents);

        if ($modified === $contents)
        {
            return;
        }

        $this->createBackupFile($global_php);

        file_put_contents($global_php, $modified);

        $this->myCommand->info('Commented out the default log initialization code in "global.php".');
    }
146700
private static function init() {
        self::$appContext = new AppContext(self::$config);

        if (isset(self::$config['customHandlers'])) {
            if (is_callable(self::$config['customHandlers'])) {
                call_user_func(self::$config['customHandlers'], self::$appContext);
            }
            else {
                throw new \Exception('Function is expected.');
            }
        }

        self::invokeAll(self::$appContext->getPreInit(), array(self::$appContext));

        $config = self::$appContext->getConfig();

        if (empty($config['appNamespace'])) {
            throw new \Exception('The root namespace for the application is required. To specify the namespace of your application, use the useNamespace method. The value must not be null or empty.');
        }

        if (empty($config['basePath'])) {
            $config['basePath'] = getcwd();
        }

        if (!defined('PHPMVC_DS')) { define('PHPMVC_DS', DIRECTORY_SEPARATOR); }
        if (!defined('PHPMVC_ROOT_PATH')) { define('PHPMVC_ROOT_PATH', $config['basePath'] . PHPMVC_DS); }
        if (!defined('PHPMVC_CORE_PATH')) { define('PHPMVC_CORE_PATH', __DIR__ .PHPMVC_DS); }
        if (!defined('PHPMVC_CONFIG_PATH')) { define('PHPMVC_CONFIG_PATH', PHPMVC_ROOT_PATH . 'config' . PHPMVC_DS); }
        if (!defined('PHPMVC_FILTER_PATH')) { define('PHPMVC_FILTER_PATH', PHPMVC_ROOT_PATH . 'filters' . PHPMVC_DS); }
        if (!defined('PHPMVC_CONTROLLER_PATH')) { define('PHPMVC_CONTROLLER_PATH', PHPMVC_ROOT_PATH . 'controllers' . PHPMVC_DS); }
        if (!defined('PHPMVC_MODEL_PATH')) { define('PHPMVC_MODEL_PATH', PHPMVC_ROOT_PATH . 'models' . PHPMVC_DS); }
        if (!defined('PHPMVC_VIEW_PATH')) { define('PHPMVC_VIEW_PATH', PHPMVC_ROOT_PATH . 'views' . PHPMVC_DS); }
        if (!defined('PHPMVC_SHARED_PATH')) { define('PHPMVC_SHARED_PATH', PHPMVC_VIEW_PATH . 'shared' . PHPMVC_DS); }
        if (!defined('PHPMVC_UPLOAD_PATH')) { define('PHPMVC_UPLOAD_PATH', PHPMVC_ROOT_PATH . 'upload' . PHPMVC_DS); }

        if (!defined('PHPMVC_APP_NAMESPACE')) {
            define('PHPMVC_APP_NAMESPACE', $config['appNamespace']);
        }
        elseif (PHPMVC_APP_NAMESPACE !== $config['appNamespace']) {
            throw new \Exception('Constant PHPMVC_CONTROLLER already defined. Re-define with other value is not possible.');
        }

        if (empty($config['routeProvider'])) {
            $config['routeProvider'] = new DefaultRouteProvider();
        }
        elseif (!$config['routeProvider'] instanceof RouteProvider) {
            throw new \Exception('The routeProvider type must be the base of "\PhpMvc\RouteProvider".');
        }

        $config['routeProvider']->init();

        if (isset($config['routes'])) {
            if (is_callable($config['routes'])) {
                $config['routes']($config['routeProvider']);
            }
            elseif (is_array($config['routes'])) {
                $provider = $config['routeProvider'];

                foreach($config['routes'][0] as $route) {
                    $provider->add($route->name, $route->template, $route->defaults, $route->constraints);
                }

                if (count($config['routes']) > 1) {
                    foreach($config['routes'][1] as $route) {
                        $provider->ingnore($route->template, $route->constraints);
                    }
                }
            }
            elseif ($config['routes'] instanceof RouteCollection) {
                $provider = $config['routeProvider'];

                foreach($config['routes'] as $route) {
                    $provider->add($route->name, $route->template, $route->defaults, $route->constraints);
                }
            }
        }

        if (empty($config['cacheProvider'])) {
            $config['cacheProvider'] = new IdleCacheProvider();
        }
        elseif (!$config['cacheProvider'] instanceof CacheProvider) {
            throw new \Exception('The $cacheProvider type must be the base of "\PhpMvc\CacheProvider".');
        }

        $config['cacheProvider']->init();

        if (isset($config['sessionProvider'])) {
            if ($config['sessionProvider'] === true) {
                $config['sessionProvider'] = new HttpSession();
            }
            elseif (!$config['sessionProvider'] instanceof HttpSessionProvider) {
                throw new \Exception('The $sessionProvider type must be the base of "\PhpMvc\HttpSessionProvider".');
            }

            $config['sessionProvider']->init();
        }

        if (empty($config['httpContext'])) {
            $info = new HttpContextInfo();
            $info->routeProvider = $config['routeProvider'];
            $info->cacheProvider = $config['cacheProvider'];
            $info->request = new HttpRequest();
            $info->response = new HttpResponse();
            $info->session = isset($config['sessionProvider']) ? $config['sessionProvider'] : null;

            $config['httpContext'] = new HttpContext($info);
        }
        elseif (!$config['httpContext'] instanceof HttpContextBase) {
            throw new \Exception('The httpContext type must be the base of "\PhpMvc\HttpContextBase".');
        }

        // default response handlers
        $response = $config['httpContext']->getResponse();

        $response->setEndHandler(function() use ($config) {
            self::invokeAll(self::$appContext->getEnd(), array(new ActionContext($config['httpContext'])));
        });

        $response->setPreSendHandler(function() use ($config) {
            self::invokeAll(self::$appContext->getPreSend(), array(new ActionContext($config['httpContext'])));
        });

        // set context and config, and invoke init handlers
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\HttpContext', 'current', $config['httpContext']);

        self::$appContext->setConfig($config);
        self::invokeAll(self::$appContext->getInit(), array(self::$appContext));
        self::$config = self::$appContext->getConfig();
    }
856641
def setup_global_logging():
    

    global global_logging_started

    if not PY3K:
        sys.exc_clear()

    if global_logging_started:
        return

    orig_logger_class = logging.getLoggerClass()
    logging.setLoggerClass(StreamTeeLogger)
    try:
        stdout_logger = logging.getLogger(__name__ + '.stdout')
        stderr_logger = logging.getLogger(__name__ + '.stderr')
    finally:
        logging.setLoggerClass(orig_logger_class)

    stdout_logger.setLevel(logging.INFO)
    stderr_logger.setLevel(logging.ERROR)
    stdout_logger.set_stream(sys.stdout)
    stderr_logger.set_stream(sys.stderr)
    sys.stdout = stdout_logger
    sys.stderr = stderr_logger

    exception_logger = logging.getLogger(__name__ + '.exc')
    sys.excepthook = LoggingExceptionHook(exception_logger)

    logging.captureWarnings(True)

    rawinput = 'input' if PY3K else 'raw_input'
    builtins._original_raw_input = getattr(builtins, rawinput)
    setattr(builtins, rawinput, global_logging_raw_input)

    global_logging_started = True
216047
public function Init()
    {
        $oGlobal = TGlobal::instance();
        $this->aUserInput = $oGlobal->GetUserData('aInput');
        if (!is_array($this->aUserInput)) {
            $this->aUserInput = array();
        }

        if (!array_key_exists(MTShopArticleCatalogCore::URL_ITEM_ID, $this->aUserInput)) {
            $oGlobal = TGlobal::instance();
            $this->aUserInput[MTShopArticleCatalogCore::URL_ITEM_ID] = $oGlobal->GetUserData(MTShopArticleCatalogCore::URL_ITEM_ID);
        }

        $aInitInputData = array('name', 'email', 'toname', 'toemail', 'comment', 'captcha');
        foreach ($aInitInputData as $sField) {
            if (!array_key_exists($sField, $this->aUserInput)) {
                $this->aUserInput[$sField] = '';
            }
        }
        $this->aUserInput = $this->FilterUserData($this->aUserInput);
    }
182818
public function write_log($level = 'error', $msg = '', $php_error = false)
    {
        /**
         * Ensure this is set correctly. Would use the constructor, however that is
         * called before the pre_system hook (as the constructor of the hook class
         * calls log_message() which in turn constructs this class. The docs LIE when
         * they say only benchmark and hooks class are loaded)
         */

        if (defined('DEPLOY_LOG_DIR')) {

            $this->_log_path = DEPLOY_LOG_DIR;

            //  If we haven't already, check to see if DEPLOY_LOG_DIR is writable
            if (is_null($this->_enabled)) {

                if (is_writable($this->_log_path)) {

                    //  Writable!
                    $this->_enabled = true;

                } else {

                    //  Not writable, disable logging and kick up a fuss
                    $this->_enabled = false;

                    //  Send developer mail, but only once
                    if (!defined('NAILS_LOG_ERROR_REPORTED')) {

                        if (isset($_SERVER['REQUEST_URI'])) {

                            $uri = $_SERVER['REQUEST_URI'];

                        } else {

                            //  Most likely on the CLI
                            if (isset($_SERVER['argv'])) {

                                $uri = 'CLI: ' . implode(' ', $_SERVER['argv']);

                            } else {

                                $uri = 'Unable to determine URI';
                            }
                        }

                        $msg     = strtoupper($level) . ' ' . ((strtoupper($level) == 'INFO') ? ' -' : '-') . ' ' . date($this->_date_fmt) . ' --> ' . $msg . "\n";
                        $appname = defined('APP_NAME') ? APP_NAME : '[Could not determine app name]';

                        $subject = 'Log folders are not writable on ' . $appname;
                        $message = 'I just tried to write to the log folder for ' . $appname . ' and found them not to be writable.' . "\n";
                        $message .= '' . "\n";
                        $message .= 'Get this fixed ASAP - I\'ll bug you every time this happens.' . "\n";
                        $message .= '' . "\n";
                        $message .= 'FYI, the entry was:' . "\n";
                        $message .= '' . "\n";
                        $message .= $msg . "\n";
                        $message .= '' . "\n";
                        $message .= 'The calling URI was:' . "\n";
                        $message .= '' . "\n";
                        $message .= $uri . "\n";
                        $message .= '' . "\n";
                        $message .= 'The path was:' . "\n";
                        $message .= '' . "\n";
                        $message .= $this->_log_path . "\n";
                        $message .= '' . "\n";
                        $message .= 'PHP SAPI Name:' . "\n";
                        $message .= '' . "\n";
                        $message .= php_sapi_name() . "\n";
                        $message .= '' . "\n";
                        $message .= 'PHP Debug Backtrace:' . "\n";
                        $message .= '' . "\n";
                        $message .= json_encode(debug_backtrace()) . "\n";

                        //  Set from details
                        try {

                            $oEmailer = Factory::service('Emailer');

                            $fromName  = $oEmailer->getFromName();
                            $fromEmail = $oEmailer->getFromEmail();

                        } catch (\Exception $e) {

                            $fromName  = 'Log Error Reporter';
                            $fromEmail = 'root@' . gethostname();
                        }

                        $to      = Environment::not(Environment::ENV_PROD) && defined('EMAIL_OVERRIDE') && EMAIL_OVERRIDE ? EMAIL_OVERRIDE : APP_DEVELOPER_EMAIL;
                        $headers = 'From: ' . $fromName . ' <' . $fromEmail . '>' . "\r\n" .
                            'X-Mailer: PHP/' . phpversion() . "\r\n" .
                            'X-Priority: 1 (Highest)' . "\r\n" .
                            'X-Mailer: X-MSMail-Priority: High/' . "\r\n" .
                            'Importance: High';

                        if (!empty($to)) {

                            @mail($to, '!!' . $subject, $message, $headers);
                        }

                        define('NAILS_LOG_ERROR_REPORTED', true);
                    }
                }
            }

        } else {

            //  Don't bother writing as we don't know where to write.
            return false;
        }

        // --------------------------------------------------------------------------

        //  Test Log folder, but only if the error level is to be captured
        $level = strtoupper($level);

        if (!isset($this->_levels[$level]) || ($this->_levels[$level] > $this->_threshold)) {

            return false;
        }

        return parent::write_log($level, $msg, $php_error);
    }
605599
protected function init()
    {
        global $wpdb;
        $this->wpdb = $wpdb;
        $this->queryGrammar = new MySqlGrammar();
        $this->postProcessor = new MySqlProcessor();
    }
1365678
private function initializeLogger()
    {
        if (Log::hasLogger()) {
            return;
        }

        $logger = new Logger($this->getConfig()['log']['name'] ?? 'foundation');

        if (!$this->getConfig()['debug'] ?? false || defined('PHPUNIT_RUNNING')) {
            $logger->pushHandler(new NullHandler());
        } elseif (($this->getConfig()['log']['handler'] ?? null) instanceof HandlerInterface) {
            $logger->pushHandler($this->getConfig()['log']['handler']);
        } elseif ($logFile = $this->getConfig()['log']['file'] ?? null) {
            $logger->pushHandler(new StreamHandler(
                    $logFile,
                    $this->getConfig()['log']['level'] ?? Logger::WARNING,
                    true,
                    $this->getConfig()['log']['permission'] ?? null
            ));
        }

        Log::setLogger($logger);
    }
919563
def teardown_global_logging():
    """"""

    global global_logging_started
    if not global_logging_started:
        return

    stdout_logger = logging.getLogger(__name__ + '.stdout')
    stderr_logger = logging.getLogger(__name__ + '.stderr')
    if sys.stdout is stdout_logger:
        sys.stdout = sys.stdout.stream
    if sys.stderr is stderr_logger:
        sys.stderr = sys.stderr.stream

    # If we still have an unhandled exception go ahead and handle it with the
    # replacement excepthook before deleting it
    exc_type, exc_value, exc_traceback = sys.exc_info()
    if exc_type is not None:
        sys.excepthook(exc_type, exc_value, exc_traceback)
    del exc_type
    del exc_value
    del exc_traceback
    if not PY3K:
        sys.exc_clear()

    del sys.excepthook
    logging.captureWarnings(False)

    rawinput = 'input' if PY3K else 'raw_input'
    if hasattr(builtins, '_original_raw_input'):
        setattr(builtins, rawinput, builtins._original_raw_input)
        del builtins._original_raw_input

    global_logging_started = False
521336
public static function init($configFile='config/settings.yml', $localConfigFile='config/settings.local.yml')
    {
        // Check what php SAPI is being used
        self::$_cli = false;
        if (strcmp(php_sapi_name(), 'cli') === 0)
            self::$_cli = true;

        // Initialize application services, Store application Object as a global
        // Services are available from global app.
        $GLOBALS['app']    = $app = new self();
        $GLOBALS['logger'] = LoggerFactory::instance()->getLogger();
        $GLOBALS['routeLogger'] = LoggerFactory::instance()->getLogger();

        $configFactory     = new ConfigurationFactory($configFile, $localConfigFile);
        $app->_config      = $configFactory->getConfig();
        
        $logFolder =  getcwd().'/logs';
        if (!file_exists($logFolder)) {
            if(!mkdir($logFolder)) {
                $logFolder = sys_get_temp_dir().'/logs';
                if(!file_exists($logFolder) && !mkdir($logFolder)) {
                    die('Insufficient privileges to create logs folder in application directory, or temp path, exiting');    
                }
            }
        }

        $file              = $logFolder.DIRECTORY_SEPARATOR.$app->_config->getApplicationContext().'-debug.log';
        $GLOBALS['logger']->addHandler($file, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()]);

        $analyticsFile = $logFolder.DIRECTORY_SEPARATOR.$app->_config->getApplicationContext().'-analytics.log';
        $GLOBALS['routeLogger']->addHandler($analyticsFile, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()], 'analytics');

        if (!self::$_cli) {
            $sessionManager = new WebSessionManager();
            $sessionManager->startSession(null, true);
            $app->_services['sessions']   = $sessionManager;

            SecurityUtils::setSecurityManager(new DefaultSecurityManager());

            $app->_subject = $app->_getSubjectFromSession($sessionManager->getActiveSession());

            $app->_services['routing']    = new RoutingEngine();
        }

        $app->_services['messaging']  = NotificationService::instance();

        return $app;
    }
878703
protected function init($mode = 0)
    {
        // initialize syslog
        if ($this->config->get('log_driver') == 'syslog') {
            $syslog_id       = $this->config->get('syslog_id', 'roundcube');
            $syslog_facility = $this->config->get('syslog_facility', LOG_USER);
            openlog($syslog_id, LOG_ODELAY, $syslog_facility);
        }

        // connect to database
        if ($mode & self::INIT_WITH_DB) {
            $this->get_dbh();
        }

        // create plugin API and load plugins
        if ($mode & self::INIT_WITH_PLUGINS) {
            $this->plugins = rcube_plugin_api::get_instance();
        }
    }
318662
public function handleInitialSettings()
    {
        $sessionClass = ReporticoSession();

        if (!$this->framework_parent && !$sessionClass::getReporticoSessionParam("awaiting_initial_defaults")) {
            $this->initial_project = false;
            $this->initial_sql = false;
            $this->initial_execute_mode = false;
            $this->initial_report = false;
            $this->initial_project_password = false;
            $this->initial_output_style = false;
            $this->initial_output_format = false;
            $this->initial_show_detail = false;
            $this->initial_show_graph = false;
            $this->initial_show_group_headers = false;
            $this->initial_show_group_trailers = false;
            $this->initial_showColumnHeaders = false;
            $this->initial_show_criteria = false;
            $this->initial_execution_parameters = false;
            $this->access_mode = false;
        }
    }
1251309
private function set_global_variable()
    {
        $var_name = "";
        
        if( null != $this->config->global_variable )
        {
            $var_name = $this->config->global_variable;
        }
        else
        {
            $var_name = $this->page->get_slug().'_options';
        }
        
        $GLOBALS[$var_name] = $this->options->get();
    }
355883
static function Init()
	{
		require_once 'verysimple/Phreeze/Controller.php';
		require_once 'verysimple/HTTP/RequestUtil.php';

		if (!self::$IS_INITIALIZED)
		{
			RequestUtil::NormalizeUrlRewrite();

			Controller::$SmartyViewPrefix = '';
			Controller::$DefaultRedirectMode = 'header';

			self::$IS_INITIALIZED = true;
		}

	}
30602
protected static function init()
    {
        // Start file.
        $backtrace        = debug_backtrace();
        self::$_startFile = $backtrace[count($backtrace) - 1]['file'];

        // Pid file.
        if (empty(self::$pidFile)) {
            self::$pidFile = __DIR__ . "/../" . str_replace('/', '_', self::$_startFile) . ".pid";
        }

        // Log file.
        if (empty(self::$logFile)) {
            self::$logFile = __DIR__ . '/../workerman.log';
        }
        $log_file = (string)self::$logFile;
        if (!is_file($log_file)) {
            touch($log_file);
            chmod($log_file, 0622);
        }

        // State.
        self::$_status = self::STATUS_STARTING;

        // For statistics.
        self::$_globalStatistics['start_timestamp'] = time();
        self::$_statisticsFile                      = sys_get_temp_dir() . '/workerman.status';

        // Process title.
        self::setProcessTitle('WorkerMan: master process  start_file=' . self::$_startFile);

        // Init data for worker id.
        self::initId();

        // Timer init.
        Timer::init();
    }
606542
private function init()
    {
        $nb_engine = CNabuEngine::getEngine();

        $session_name = session_name();
        $nb_engine->traceLog("Session Name", $session_name);
        if (array_key_exists($session_name, $_GET)) {
            $sessid = filter_input(INPUT_GET, $session_name);
            if (preg_match('/^[a-zA-Z0-9]{26}$/', $sessid)) {
                session_id($sessid);
                $nb_engine->traceLog("Session source", "GET");
            } else {
                $nb_engine->traceLog("Session source", "COOKIE");
            }
        } else {
            $nb_engine->traceLog("Session source", "COOKIE");
        }
    }
255898
protected static function init()
    {
        set_error_handler(function($code, $msg, $file, $line){
            Worker::safeEcho("$msg in file $file on line $line\n");
        });

        // Start file.
        $backtrace        = debug_backtrace();
        static::$_startFile = $backtrace[count($backtrace) - 1]['file'];


        $unique_prefix = str_replace('/', '_', static::$_startFile);

        // Pid file.
        if (empty(static::$pidFile)) {
            static::$pidFile = __DIR__ . "/../$unique_prefix.pid";
        }

        // Log file.
        if (empty(static::$logFile)) {
            static::$logFile = __DIR__ . '/../workerman.log';
        }
        $log_file = (string)static::$logFile;
        if (!is_file($log_file)) {
            touch($log_file);
            chmod($log_file, 0622);
        }

        // State.
        static::$_status = static::STATUS_STARTING;

        // For statistics.
        static::$_globalStatistics['start_timestamp'] = time();
        static::$_statisticsFile                      = sys_get_temp_dir() . "/$unique_prefix.status";

        // Process title.
        static::setProcessTitle('WorkerMan: master process  start_file=' . static::$_startFile);

        // Init data for worker id.
        static::initId();

        // Timer init.
        Timer::init();
    }
100355
public static function initialize()
    {
        if (!isset($GLOBALS['_SESSION']) or !($GLOBALS['_SESSION'] instanceof self)) {
            $GLOBALS['_SESSION'] = self::getInstance();
        }

        return self::getInstance();
    }