Writes log in file. Do NOT actually saves the task run
@return bool
436116
public function saveTaskRun()
    {
        //if monolog not found does nothing
        if (!class_exists('Monolog\Logger')) {
            return false;
        }
        $logger = new Logger('cron_logger');
        $logger->pushHandler(new RotatingFileHandler($this->logs_folder . $this->log_name));
        $task = TaskFile::taskGet($this->task_id);
        if (self::RUN_STATUS_STARTED == $this->status) {
            $message = 'task ' . $task->getCommand() . ' just started';
        } else {
            $message = 'task ' . $task->getCommand() . ' ended with status ' . $this->status
                . ', execution time ' . $this->execution_time . ', output: ' . PHP_EOL . $this->output;
        }
        return $logger->addNotice($message);
    }
787372
def writeLogToFile(self):
        
        if not os.path.exists(self.logFolder):
            os.mkdir(self.logFolder)

        with open(self.logFile, mode='a') as f:
            f.write('\n\n' + self.log)
606070
public function taskDelete()
    {
        $tasks = self::taskFileLoad();

        if (isset($tasks[$this->task_id])) {
            unset($tasks[$this->task_id]);

            return self::taskFileSave($tasks);
        }
        return false;
    }
590519
private function _writeLog($msg) {
        $log = "-------------------------------------\n";
        $log .= date('Y-m-d H:i:s') . ":\n";
        $log .= $msg."\n";
        $log .= "-------------------------------------\n";
        file_put_contents($this->_output, $log, FILE_APPEND | LOCK_EX);
    }
1332075
protected static function should_log() : bool {
        global $CFG;

        // Respect the config setting.
        if (isset($CFG->task_logmode) && empty($CFG->task_logmode)) {
            return false;
        }

        $loggerclass = self::get_logger_classname();
        if (empty($loggerclass)) {
            return false;
        }

        return $loggerclass::is_configured();
    }
161965
public function flush()
    {
        if (null == $this->buildLogFile) {
            $this->resetLogQueue();

            return;
        }
        $messageElements = array();
        for ($i = count($this->logQueue) - 1; $i >= 0; --$i) {
            $message = $this->logQueue[$i];
            $messageString = '<message priority="'.$message->priority.'" ';
            $messageString .= 'timestamp="'.$message->timestamp.'" ';
            $messageString .= 'time="'.date('Y-m-d H:i:s - T', $message->timestamp).'"><![CDATA[';
            $messageString .= base64_encode($message->message);
            $messageString .= ']]></message>';

            $messageElements[] = $messageString;
        }

        $previousLogMessages = '';

        $dirName = dirname($this->buildLogFile);
        if (!file_exists($dirName)) {
            mkdir($dirName, 0755, true);
        }
        if (file_exists($this->buildLogFile)) {
            // copying to temporary file for later inclusion via fgets, less memory consuming
            copy($this->buildLogFile, $this->buildLogFile.'.temp');
        }
        $fh = fopen($this->buildLogFile, 'w+');
        if (is_resource($fh)) {
            fputs($fh, '<?xml version="1.0"?>');
            fputs($fh, "\n");
            fputs($fh, '<build>');
            fputs($fh, "\n");
            fputs($fh, implode("\n", $messageElements));
            fputs($fh, "\n");
            if (file_exists($this->buildLogFile.'.temp')) {
                $fht = fopen($this->buildLogFile.'.temp', 'r');
                if (is_resource($fht)) {
                    $lineCounter = 0;
                    while ($line = fgets($fht)) {
                        // skip first two lines (xml decl and build opening element
                        if ($lineCounter > 2) {
                            fputs($fh, $line);
                        }
                        ++$lineCounter;
                    }
                    fclose($fht);
                    unlink($this->buildLogFile.'.temp');
                } else {
                    self::error('Cannot include previous log messages');
                }
            } else {
                fputs($fh, '</build>');
            }
            //fputs($fh, $previousLogMessages);
            fclose($fh);
            //file_put_contents($this->buildLogFile, $buildXml);
        } else {
            self::error('Cannot open: '.$this->buildLogFile.' for writing.');
        }
        $this->resetLogQueue();
    }
23089
private function write() {

		if(null === $this -> directory) {
			return trigger_error(sprintf('Directory used in %s() can not be NULL', __METHOD__), E_USER_ERROR);
		}

		if(false === is_string($this -> code)) {
			return trigger_error(sprintf('Code used in %s() must be of the type string, "%s" given', __METHOD__, gettype($this -> code)), E_USER_ERROR);
		}

		$file = $this -> getFileName();
		$file = new File($this -> directory . $file);

		//Create file if not exists
		if(false === $file -> exists()) {
			$file -> create();
		}

		//Append data to file after flushing it
		$file -> flush() -> append($this -> code);

		return $this;
	}
743617
public function save()
    {

        // Create config folder if it does not exist.
        $fs = new Filesystem();
        $dumper = new Dumper();

        if (!$fs->exists(getenv('HOME').'/.terra')) {
            try {
                $fs->mkdir(getenv('HOME').'/.terra/apps');
            } catch (IOExceptionInterface $e) {
                return false;
            }
        }

        try {
            $fs->dumpFile(getenv('HOME').'/.terra/terra', $dumper->dump($this->config, 10));

            return true;
        } catch (IOExceptionInterface $e) {
            return false;
        }
    }
1035483
protected function doExecute()
    {
        $tmpFile = WINDWALKER_TEMP . '/offline';

        if ($this->offline) {
            File::write($tmpFile, 'off');
        } elseif (is_file($tmpFile)) {
            File::delete($tmpFile);
        }

        $this->out()->out($this->description);

        return true;
    }
572131
public function write()
    {
        $current = $this->getUserAgent() + ['agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'), 'ip' => $this->getClientIp()];
        $last = $this->getFileArray()->exists(0) ? $this->getFileArray()->get(0) : [];

        //Removes the first record (last in order of time), if it has been saved
        //  less than an hour ago and if the user agent data are the same
        if ($last && (new Time($last->get('time')))->modify('+1 hour')->isFuture()
            && $last->extract(['agent', 'browser', 'ip', 'platform', 'version']) == $current
        ) {
            $this->getFileArray()->delete(0);
        }

        //Adds the current request, takes only a specified number of records and writes
        return $this->getFileArray()->prepend(new Entity($current + ['time' => new Time]))
            ->take(getConfig('users.login_log'))
            ->write();
    }
921032
public function write()
    {
        $lines = array();

        foreach ($this->data as $fetch) {
            $data = array($fetch['url'], $fetch['length'], $fetch['filename']);
            array_push($lines, join(' ', $data) . "\n");
        }

        if (count($lines) == 0) {
            if (file_exists($this->fileName)) {
                unlink($this->fileName);
            }
        } else {
            writeFileText($this->fileName, $this->fileEncoding, join('', $lines));
        }
    }
1027067
public static function write() 
	{
		if ( empty( static::$_data ) )
		{
			return;
		}
		
		$buffer = date("H:i:s")." - ".CCServer::method().' '.CCServer::server('REQUEST_URI')."\n";
		$buffer .= implode( "\n", static::$_data );
		
		CCFile::append( CCStorage::path( 'logs/'.date( 'Y-m' ).'/'.date( 'd' ).'.log' ), $buffer."\n" );
		
		// clear
		static::clear();
	}
914196
public function lock()
    {
        if (!$this->isLocked()) {
            $file = fopen($this->getFilePath(), 'w');
            if ($file) {
                fwrite($file, getmypid());
                fclose($file);
                return true;
            }
        }
        return false;
    }
17056
protected function writeProcessIdFile()
    {
        // Verify the process id is valid.
        if ($this->processId < 1) {
            $this->getLogger()->emergency('The process id is invalid.');

            return false;
        }

        // Get the application process id file path.
        $file = $this->config->get('application_pid_file');

        if (empty($file)) {
            $this->getLogger()->error('The process id file path is empty.');

            return false;
        }

        // Make sure that the folder where we are writing the process id file exists.
        $folder = dirname($file);

        if (!is_dir($folder) && !@ mkdir($folder, $this->get('folder_permission', 0755))) {
            $this->getLogger()->error('Unable to create directory: ' . $folder);

            return false;
        }

        // Write the process id file out to disk.
        if (!file_put_contents($file, $this->processId)) {
            $this->getLogger()->error('Unable to write proccess id file: ' . $file);

            return false;
        }

        // Make sure the permissions for the proccess id file are accurate.
        if (!chmod($file, $this->get('file_permission', 0644))) {
            $this->getLogger()->error('Unable to adjust permissions for the proccess id file: ' . $file);

            return false;
        }

        return true;
    }
290712
private function writeToFile() {

		$logger = $this -> getLogger();
		$logger -> setDirectory(Path :: get('log-error'));


		$error = $this -> error -> toJson($this -> options['types']);

		if(false === $error) {
			$this -> error -> setContext(null);
			$this -> error -> setBacktrace(null);
		}

		$error = $this -> error -> toJson($this -> options['types']);
		$logger -> write($this -> error -> toJson($this -> options['types']));
	}
238021
public function write_log($msg = '', $log_level = 0)
    {

        // log level check
        if ($this->log_level > (int)$log_level) return true;

        try {
            if (!$this->file->open((string)"$this->_log_path/$this->_file_name") && !$this->file->create_file("$this->_log_path/$this->_file_name")) {
                // $message = null, $code = null, $previous = null
                throw new LogException((string)"file: $this->_log_path/$this->_file_name couldn't be created.");
            }

            // check for the 2nd time
            $this->file->open("$this->_log_path/$this->_file_name");

            // if it doesn't exist add next line @ the end of the msg
            if (strpos($msg, "\n") === false) {
                $msg = "[" . (string)date(self::LOG_DATE_FORMAT) . (string)"] $msg " . "\n";
            } else {
                $msg = "[" . (string)date(self::LOG_DATE_FORMAT) . (string)"] $msg";
            }


            if ($this->file->append($msg) === false) {
                // some code
            }
            /*
             * while ( $this->file->append($msg) === false ) { /* // sleep 1
             * second sleep(1); if ( $start_time + 10 == time() ) { throw new
             * LogException("Sleep time for file:
             * $this->_log_path/$this->_file_name exceeded 10
             * seconds\n[msg]$msg"); break; } }
             */

        } catch (LogException $e) {
            error_log($e->getMessage());
        }

        return true;
    }
79860
private function write_log()
    {
        $log_output_file = $this->getOptions()->getLogOutputFile();
        if (!$log_output_file || !is_writable($log_output_file)) {
            return;
        }

        $frames = Frame::$ID_COUNTER;
        $memory = memory_get_peak_usage(true) / 1024;
        $time = (microtime(true) - $this->startTime) * 1000;

        $out = sprintf(
            "<span style='color: #000' title='Frames'>%6d</span>" .
            "<span style='color: #009' title='Memory'>%10.2f KB</span>" .
            "<span style='color: #900' title='Time'>%10.2f ms</span>" .
            "<span  title='Quirksmode'>  " .
            ($this->quirksmode ? "<span style='color: #d00'> ON</span>" : "<span style='color: #0d0'>OFF</span>") .
            "</span><br />", $frames, $memory, $time);

        $out .= ob_get_contents();
        ob_clean();

        file_put_contents($log_output_file, $out);
    }