Wrties to the system log

@param  string  $level     The log message's level
@param  string  $msg       The message to write to the log file
@param  boolean $php_error Whether or not this is a PHP error

@return boolean
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);
    }
904914
protected function logMessage($level, $message)
    {
        if (array_search($level, $this->levels) > $this->levelPosition) {
            return;
        }

        echo $message;
    }
1344631
public function log($level, $message, array $context = array()) {
		$message = preg_replace("/[\r\n]+/", $this->replacement, $message);
		$this->logger()->log($level, $message, $context);
	}
12282
private function message($msg, $level)
    {
        if ($this->transcoder) {
            $this->transcoder->dispatch(TranscodeEvents::MESSAGE, new MessageEvent($msg, $level, $this));
        }
    }
673721
public function log($level, $message, array $context = array())
    {
        try
        {
            return $this->logger->log($level, $message, $context);
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        throw new WriteException("Record with undefined level could not be logged.", 0, $ex);
    }
708163
public function log($level, $message, $context = array())
    {
        $level = isset($this->levels[$level]) ? $level : $this->level;

        // Check if the level would be handled
        if (isset($this->levels[$level])) {
            if ($this->levels[$level] < $this->levels[$this->handledLevel]) {
                return false;
            }
        }

        return $this->writeLog($level, $message, $context);
    }
706515
public function log($level, $message, array $context = [])
    {
        $context_output = empty($context) ? '' : sprintf(' :: %s', json_encode($context));

        $logline = sprintf("[%s] %s%s\n", strtoupper($level), $message, $context_output);

        $handle = in_array($level, self::ERROR_LEVELS, false) ? STDERR : STDOUT;

        fwrite($handle, $logline);
    }
356441
public function log($level, $message, array $context = array())
    {
        error_log(sprintf($this->getDefaultLogFormat(), date('Y-m-d H:i:s'), gethostname(), $level, $message, json_encode($context)));
    }
839749
public function log($level, $message, array $context = [])
    {
        $record = new LogRecord($level, $message);

        // add all messages to session log
        $this->session->addRecord($record);

        // write record into log only if it is enough by level
        if ($this->logLevel >= $level) {
            $this->write($record);
        }
    }
499681
public function log($level, $message, array $context = array())
    {
        $eol = isset($context['newLine']) && $context['newLine'] === false ? '' : PHP_EOL;
        
        if ($this->addLeveLMarkersToMessage && !empty($level)) {
            echo '<',$level,'>',$message,'</',$level,'>',$eol;
        } else {
            echo $message,$eol;
        }
    }
1246733
protected  function writeMessage($level, $msg, $vars = null) {
		// Because of date('u')-PHP-bug (always 00000)
		$mtimeParts = explode(' ', microtime());

		$repl = array(
			Logger::PATTERN_CLASS => $this->classContext,
            Logger::PATTERN_CLASSNAME => StringUtils::afterLast($this->classContext, '\\'),
			Logger::PATTERN_LEVEL => str_pad($level, 5, ' ', STR_PAD_RIGHT),
			Logger::PATTERN_MESSAGE => $msg,
			Logger::PATTERN_TIMESTAMP => date($this->dtFormat, $mtimeParts[1]) . ',' . substr($mtimeParts[0], 2) /* date('Y-m-d H:i:s,u') */
		);

		error_log(str_ireplace(array_keys($repl), $repl, $this->pattern) . "\r\n", 3, $this->logfilePath);
	}
70797
private function log($mesg, $level)
    {
        if ($this->record && ($level <= $this->loglevel) && $this->out != null) {
            $this->out->write($mesg . PHP_EOL);
        }
    }
277266
public function log($level, $message, array $context = array())
    {
        return error_log(self::PREFIX.' '.strtoupper($level).': '.$message.' '.
            (!empty($context) ? print_r($context, true) : ''));
    }
158151
public function log($msg, array $data = [], $level = Logger::INFO): void
    {
        $this->mgr->log($msg, $data, $level);
    }
900436
public static function log ($message, $level = null) {
		$level = ($level !== null) ? $level : self::$default_level;
		return self::write (self::get_struct ($message, $level));
	}
454462
protected function logPHPDebug($function, $msg) {
		if ($this->classparams['debug_php'] === true) {
			$output = "[DEBUG] [$function] ".$this->arrayexpand($msg);
			error_log($output);
		}
	}
1113257
public function log($level, $message, array $context = []) {
		$message = trim($message);
		$summary = Text::truncate($message, 255);

		$data = [
			'type' => $level,
			'summary' => $summary,
			'message' => $message,
			'context' => trim(print_r($context, true)),
			'count' => 1,
		];
		$log = $this->newEntity($data);

		return (bool)$this->save($log);
	}