Open logs
@return void
969031
public static function openLogs()
    {
        if (Daemon::$config->logging->value) {
            Daemon::$logpointer = fopen(Daemon::$config->logstorage->value, 'a');
            if (isset(Daemon::$config->group->value)) {
                chgrp(Daemon::$config->logstorage->value, Daemon::$config->group->value); // @TODO: rewrite to async I/O
            }
            if (isset(Daemon::$config->user->value)) {
                chown(Daemon::$config->logstorage->value, Daemon::$config->user->value); // @TODO: rewrite to async I/O
            }
            if ((Daemon::$process instanceof Thread\Worker) && FileSystem::$supported) {
                FileSystem::open(Daemon::$config->logstorage->value, 'a!', function ($file) {
                    Daemon::$logpointerAsync = $file;
                    if (!$file) {
                        return;
                    }
                });
            }
        } else {
            Daemon::$logpointer = null;
            Daemon::$logpointerAsync = null;
        }
    }
1114400
protected function log()
    {

        $this->worker
            ->setInstance($this->instance);
        // If instance can be called
        if($this->worker->ping()) {
            $infos = $this->worker->getInfos();
            $createdAt = new \DateTime();

            $log = $this->logManager->createNew();
            $log->setMemory($infos['Memory']['used_memory']);
            $log->setCpu($infos['CPU']['used_cpu_sys']);
            $log->setNbClients(sizeof($this->worker->getClients()));
            $log->setCreatedAt($createdAt);
            // Add log
            $this->instance->addLog($log);
        }
    }
1067638
private function startLogging()
    {
        $this->loggingStart = round(microtime(true) * 1000);
        $this->lastLog = $this->loggingStart;
    }
384847
protected function open()
    {
        if (isset($this->options['stdin'])) {
            $this->input = $this->options['stdin'];
        } else {
            $this->input = fopen('php://stdin', 'r');
        }
        if (isset($this->options['stdout'])) {
            $this->output = $this->options['stdout'];
        } else {
            $this->output = fopen('php://stdout', 'w');
        }
        while (true) {
            $line = $this->read($this->input);
            if ($this->isEndOfEnvironmentVariables($line)) {
                break;
            }
            $this->readEnvironmentVariable($line);
        }
        $this->logger->debug(print_r($this->variables, true));
    }
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);
    }
225319
public function logging( $log = false )
    {
        if ( $log !== false ) {
            if ( ! ini_get('log_errors') ) {
                ini_set('log_errors', true);
            }
            if ( ! ini_get('error_log') ) {
                ini_set('error_log', $log);
            }
        }
    }
729226
private static function _openLogFile()
    {
        try {
            self::$_file = fopen(self::$_file, "a");

            if (!self::$_file) {
                self::$_file = null;
                return false;
            }
        } catch (Exception $e) {
        }
        return true;
    }
293216
def open_session_log(self, filename, mode="write"):
        """"""
        if mode == "append":
            self.session_log = open(filename, mode="ab")
        else:
            self.session_log = open(filename, mode="wb")
        self._session_log_close = True
23671
private function writeLogs(): void
    {
        // Write logs
        $fileName = $this->getApp()->getConfig()->getDirectory(ConfigInterface::DIR_VAR_LOGS) . '/Berlioz.log';

        if (is_resource($this->fp) || is_resource($this->fp = @fopen($fileName, 'a'))) {
            if (count($this->logs) > 0) {
                foreach ($this->logs as $key => $log) {
                    if (!$log['written']) {
                        $line = sprintf("%-26s %-11s %s\n",
                                        \DateTime::createFromFormat('U.u', number_format($log['time'], 6, '.', ''))
                                                 ->format('Y-m-d H:i:s.u'),
                                        '[' . $log['level'] . ']',
                                        $log['message']);

                        if (@fwrite($this->fp, $line) !== false) {
                            $this->logs[$key]['written'] = true;
                        }
                    }
                }
            }
            unset($log);
        }
    }
1067816
public function openLog() {
        if ($this->file) {

            $logDir = dirname($this->file);
            if (!is_dir($logDir) || !file_exists($logDir)) {
                @mkdir($logDir, 0755, true);
            }

            if (!file_exists($this->file)) {
                $touched = touch($this->file);
                if (!$touched) {
                    throw new \Exception("Unable to open log file '{$this->file}', could not create");
                }
            }

            if (!is_writable($this->file)) {
                throw new \Exception("Unable to open log file '{$this->file}', not writable");
            }
            $this->fr = fopen($this->file, 'a');
        }
    }
242620
@Override
    public void openLog() throws LogCorruptedException, LogAllocationException, InternalLogException,
                    LogIncompatibleException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "openLog", this);

        _recoveryLog.openLog();

        if (tc.isEntryEnabled())
            Tr.exit(tc, "openLog");
    }
45551
public function logger() : void
  {
    LogHandler::$disk = DEPConfig::$appdir . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;
    LogHandler::$name = config('app.logger.name');
    LogHandler::$log  = config('app.logger.log');
    LogHandler::$env  = config('app.env');

    LogHandler::event(function($env, $level, $message, $array) {
      Events::trigger('output.log', [$env, $level, $message, $array]);
    });
  }
643849
protected function setupLogging()
    {
        $level = $this->options->getOpt('loglevel', $this->logdefault);
        if (!isset($this->loglevel[$level])) $this->fatal('Unknown log level');
        foreach (array_keys($this->loglevel) as $l) {
            if ($l == $level) break;
            unset($this->loglevel[$l]);
        }
    }
353229
protected function registerLogs()
    {
        $this->app->singleton('logs', function($app)
        {
            $config = $this->app->config->get('logs');

            if ($config['adapter'] == 'loggly') {

                return new Adapters\Loggly();

            } elseif ($config['adapter'] == 'stackdriver') {

                return new Adapters\Stackdriver();

            } else {

                return new Adapters\Monolog();

            }
            
        });
    }
1109228
public function export()
    {
        openlog($this->identity, LOG_ODELAY | LOG_PID, $this->facility);
        foreach ($this->messages as $message) {
            syslog($this->_syslogLevels[$message[1]], $this->formatMessage($message));
        }
        closelog();
    }
469544
public function logNotification()
    {
        try {
            $this->logNotificationContents();
            $this->ipnLogFile->writeLine("=============================================================================");
            $this->ipnLogFile->closeFile();
        } catch (Exception $ex){
            error_log($ex->getMessage());
        } 
    }
961521
public function log()
    {
        if (isCLI()) {
            $message = $this->getContentForFile();
            $this->writeToLogFile($message);
            return $message;
        } else {
            if ($this->outputMedium !== static::MEDIUM_STDOUT) {
                $this->writeToLogFile($this->getContentForFile());
            }

            if ($this->outputMedium !== static::MEDIUM_FILE) {
                return $this->getResponse();
            }
        }
    }