Writes log info to a file
@param $msg string the message to write out
@param $path string the location to write the messages
@return null
180284
static function log($msg,$path = "") {
    if(empty($path)){
      $path = MF_FILES_DIR;
    }

    if(!is_string($msg)){
      $msg = print_r($msg,true);
    }

    $fp = fopen($path.'magic_fields.log', 'a+');
    $date = gmdate( 'Y-m-d H:i:s' );
    fwrite($fp, "$date - $msg\n");
    fclose($fp);
   }
480080
public function write($level, $message, array $context = array())
    {
        $context = array('__context' => $context);

        $log = $this->format($level, $message, $context);
        $this->setLastLogLine($log);
        echo $log;
    }
1045029
public function writeToFile(string $path)
    {
        $sitemap = $this->getSitemap();

        if ($this->maximumTagsPerSitemap) {
            $sitemap = SitemapIndex::create();
            $format = str_replace('.xml', '_%d.xml', $path);

            // Parses each sub-sitemaps, writes and pushs them into the sitemap
            // index
            $this->sitemaps->each(function (Sitemap $item, int $key) use ($sitemap, $format) {
                $path = sprintf($format, $key);

                $item->writeToFile(sprintf($format, $key));
                $sitemap->add(last(explode('public', $path)));
            });
        }

        $sitemap->writeToFile($path);

        return $this;
    }
542289
private function write(string $file, string $msg)
    {
        // 将文件名中的目录分隔符标准化
        $file = str_replace('\\', '/', $file);

        // 在日志目录下创建年目录
        $path = $this->dirRoot . date('Y-m-d') . '/' . $file . '.log';
        makeDir(dirname($path));

        // 写入文件
        return write($path, $msg, FILE_APPEND | LOCK_EX);
    }
358417
public function log($msg, $level = self::INFO, array $data = [])
    {
        if (is_numeric($level) && $level > $this->level) {
            return true;
        }

        $strData = $data ? json_encode($data) : '';

        if ($this->toSyslog) {
            return $this->sysLog($msg . ' ' . $strData, $level);
        }

        $label = self::getLevelName($level);
        $ds = FormatHelper::microTime(microtime(true));

        // [$this->getPidRole():$this->pid] $msg
        $logString = sprintf("[%s] [%s] %s %s\n", $ds, $label, trim($msg), $strData);

        // if not in daemon, print log to \STDOUT
        if (!$this->toConsole) {
            $this->stdout($logString, false);
        }

        if ($this->fileHandle) {
            $this->count++;
            $this->cache[] = Cli::clearColor($logString);

            if ($this->count >= $this->logThreshold || $this->fileIsChanged()) {
                $this->flush();
            }
        }

        return true;
    }
340712
public function writePHPDocMethod($path = '')
    {
        if (empty($path)) {
            $path = realpath($this->rootPath . $this->DEFAULT_API_JSON_PATH);
            if (empty($path)) {
                $path = $this->rootPath . $this->DEFAULT_API_JSON_PATH;
            }
            $path = preg_replace('/\.[^.]+?$/', '.php', $path);
        }
        if (file_exists($path)) {
            rename($path, $path . '.bak');
        }

        $data = $this->methodData;
        $filterParams = ['data' => $data, 'definition' => $this->data, 'source' =>
            $this->sourceData];

        $methods = array_merge(["<?php", "/** "], $data ? : [], [" */", ""]);
        $methods = $this->applyFilter('DocMethodFinalArray', $methods, $filterParams);
        $methodText = implode("\n", $methods);
        $methodText = $this->applyFilter('DocMethodFinalText', $methodText, $filterParams);

        return file_put_contents($path, $methodText);
    }
939519
function writeToLog($message) {
		if ($this->logFile) {
			$timestamp = date("Y-m-d H:i:s");
			$timestamp = str_pad($timestamp, 20);
			if (isset($_SERVER["REMOTE_ADDR"])) {
				$ip = $_SERVER["REMOTE_ADDR"];
			} else {
				$ip = "Unknown IP";
			}
			$ip = str_pad($ip, 15);
			$taggedMessage = "$timestamp $ip $message\n";
			file_put_contents($this->logFile, $taggedMessage, FILE_APPEND);
		}
		if ($this->logCallback) {
			call_user_func_array($this->logCallback, array($message));
		}
	}
681843
protected function log($msg, $color = 'default')
    {
        if (!$this->quiet) {
            if ('default' !== $color) {
                $msg = $this->colorize($color, $msg);
            }
            fwrite($this->stderr, $msg."\n");
        }
    }
40549
static function write( $message, $logName = 'common.log', $dir = 'var/log' )
    {
        $fileName = $dir . '/' . $logName;
        $oldumask = @umask( 0 );

        $fileExisted = file_exists( $fileName );
        if ( $fileExisted and
             filesize( $fileName ) > eZLog::maxLogSize() )
        {
            if ( eZLog::rotateLog( $fileName ) )
                $fileExisted = false;
        }
        else if ( !$fileExisted and !file_exists( $dir ) )
        {
            eZDir::mkdir( $dir, false, true );
        }

        $logFile = @fopen( $fileName, "a" );
        if ( $logFile )
        {
            $time = strftime( "%b %d %Y %H:%M:%S", strtotime( "now" ) );
            $logMessage = "[ " . $time . " ] $message\n";
            @fwrite( $logFile, $logMessage );
            @fclose( $logFile );
            if ( !$fileExisted )
            {
                $ini = eZINI::instance();
                $permissions = octdec( $ini->variable( 'FileSettings', 'LogFilePermissions' ) );
                @chmod( $fileName, $permissions );
            }
            @umask( $oldumask );
        }
        else
        {
            eZDebug::writeError( 'Couldn\'t create the log file "' . $fileName . '"', __METHOD__ );
        }
    }
1003469
public function writeJson($path, array $config)
    {
        $jsonFile = new JsonFile($path);
        $jsonFile->write($this->prepareConfig($config));
    }
746467
public static function writeLines($path, $lines)
    {
        if (is_file($path) && !is_writable($path)) {
            throw new RuntimeException("File '$path' is not a writable file");
        }

        // make sure every line has only one newline at the end
        $lines = array_map(function ($line) {
            return rtrim($line);
        }, $lines);

        $bytes = file_put_contents($path, implode("\n", $lines));
        if ($bytes === false) {
            throw new RuntimeException("Something went wrong while writing content to '$path'");
        }

        return true;
    }
643218
public static function write_log($chain, $type, $file="", $line=""){
        /*if(filesize(PATHAPP . 'logs/log.txt') > 100000){           
            $arch= fopen(PATHAPP . 'logs/log.txt', "w");
            fclose($arch); 
        }*/
        $arch = fopen(PATHAPP . 'logs/log-' . date('Y-m-d') . '.txt', "a+"); 
        if(ENOLA_MODE == 'HTTP'){
            fwrite($arch, "[".date("Y-m-d H:i:s.u")." ".filter_input(INPUT_SERVER, 'REMOTE_ADDR')." "." - $type ] ".$chain." - $file - $line \n");
        }else{
            fwrite($arch, "[".date("Y-m-d H:i:s.u")." MODE CLI "." - $type ] ".$chain." - $file - $line \n");
        }
        fwrite($arch, "---------- \n");
        fclose($arch);
    }
985578
public function write($path, $contents, array $config = []) {
        return $this->getFileSystem()->write($path, $contents, $config);
    }
291434
public static function log($msg)
    {
        $msg = $msg."\n";
        if(static::$_status === static::STATUS_STARTING || !static::$daemonize)
        {
            echo $msg;
        }
        file_put_contents(static::$logFile, date('Y-m-d H:i:s') . " " . $msg, FILE_APPEND | LOCK_EX);
    }
762151
public static function log($msg)
    {
        if (!self::$_enabled) {
            return;
        }

        if (is_null(self::$_file)) {
            echo "log: $msg\n";
            return;
        }

        return self::_logToFile($msg);
    }
1280440
public static function write($file_path = null, $content, $type = 'a', $force = false, array &$logs = array())
    {
        if (is_null($file_path)) {
            return null;
        }
        if (!file_exists($file_path)) {
            if (true===$force) {
                self::touch($file_path, $logs);
            } else {
                $logs[] = sprintf('File path "%s" to copy was not found.', $file_path);
                return false;
            }
        }
        if (is_writable($file_path)) {
            $h = fopen($file_path, $type);
            if (false !== fwrite($h, $content)) {
                fclose($h);
                return true;
            }
        }
        $logs[] = sprintf('Can not write in file "%s".', $file_path);
        return false;
    }
813806
protected function sysLog($msg, $level)
    {
        switch ($level) {
            case self::EMERG:
                $priority = LOG_EMERG;
                break;
            case self::ERROR:
                $priority = LOG_ERR;
                break;
            case self::WARN:
                $priority = LOG_WARNING;
                break;
            case self::DEBUG:
                $priority = LOG_DEBUG;
                break;
            case self::INFO:
            case self::PROC_INFO:
            case self::WORKER_INFO:
            default:
                $priority = LOG_INFO;
                break;
        }

        if (!$ret = syslog($priority, $msg)) {
            $this->stderr("Unable to write to syslog\n");
        }

        return $ret;
    }