Writing log

@param number level log
@param string
@param array
326249
function write($level,$text,$context = []){
		if(isset($this->log[$level])){
		
			$log = $this->log[$level];

			$log->addRecord($level,$text,$context);
		}
	}
548035
public function log($data, $level = self::LEVEL_INFO, $type = null)
    {
        if (!is_string($data)) {
            $data = print_r($data, true);
        }

        file_put_contents(
            $this->getLogDirectory() . '/' . $this->getLogFilename(),
            $this->getLogMessage($data, $level, $type),
            FILE_APPEND
        );
    }
886879
protected function write(array $record) {
        $context = '';
        if (isset($record['context']) && is_array($record['context']) && (count($record['context']) > 0)) {
            $flattenedContext = [];
            foreach($record['context'] as $key => $value) {
                if (is_array($value)) {
                    continue;
                }

                $flattenedContext[] = "$key = $value";
            }

            $context = implode(", ", $flattenedContext);
        }

        $this->logger->log($record['channel'], $record['level_name'], $record['message'], $context);
    }
641514
@Override
    public void log(Level level, String msg) {
        if (isLoggable(level)) {
            LogRecord logRecord = createLogRecord(level, msg, null, null, null, null, null);
            log(logRecord);
        }
    }
639559
protected function write($message, $level, array $addition = array(), $to = "")
    {
        // 0: function write; 1: function debug|info|notice...; 2: function of caller
        $traceLevel = 2;

        $trace = debug_backtrace();
        $class = empty($trace[$traceLevel]["class"]) ? "" : $trace[$traceLevel]["class"];
        $type = empty($trace[$traceLevel]["type"]) ? "" : $trace[$traceLevel]["type"];
        $function = empty($trace[$traceLevel]["function"]) ? "" : $trace[$traceLevel]["function"];
        $method = $class . $type . $function;

        if (empty($this->file)) {
            throw new \RuntimeException("Log File Absent");
        } elseif (!file_exists(dirname($this->file))) {
            throw new \RuntimeException("Folder Not Exists: [" . dirname($this->file) . "]");
        }

        $time     = $this->bracket(date("Y-m-d H:i:s"));
        $logId    = $this->bracket($this->logId);
        $ip       = $this->bracket(Request::getClientIp(true));
        $level    = $this->bracket($level);
        $source   = $this->bracket($method);
        $message  = $this->bracket($message);
        $addition = json_encode($addition);

        $log = implode(" ", array($time, $logId, $ip, $level, $source, $message, $addition));

        self::to($log, $to ?: $this->file);
    }
273683
protected function innerWrite($log, $level = 1, $prefix = null) {
        $level = intval($level);
        if(intval($level) < $this->log_level || $this -> out === null){
            return;
        }
        
        $timestamp = time();
        
        $prefix = $prefix === null ? $this->prefix : $prefix;
        
        $tag = $this->tags[$level];
        
        $msg = "[$tag][$timestamp][$prefix] $log; \n";
        
        if (is_callable($this -> out)) {
            $out = $this -> out;
            $out($msg . '<br />');   // if out to page , add the BR, easy to watch 
            return;
        }
        
        fwrite($this -> out, $msg);
    }
660282
public function log($level, $message, array $context = array())
    {
        $message = $this->formatMessage($level, $message, $context);        
        $this->write($message);
    }
1173729
static function record($message,$level=self::ERR,$record=false) {
        if($record || false !== strpos(C('LOG_LEVEL'),$level)) {
            self::$log[] =   "{$level}: {$message}\r\n";
        }
    }
1297898
public function log($level, $message, array $context = array())
    {
        $messageArray = [
            date('Y/m/d H:i:s')." [". $level . "] " . $message
        ];

        if (!empty($context)) {
            $messageArray[] = 'Context:';
            foreach ($context as $key => $value) {
                $messageArray[] =  $key . ' => ' . var_export($value, true);
            }
        }
        $trace = $this->getTrace();
        $messageArray[] = 'Trace:';
        $messageArray[] = $trace['trace'];

        $file = $this->path . DIRECTORY_SEPARATOR . 'application.log';
        if (!file_exists($this->path)) {
            mkdir($this->path, 0777, true);
        }

        file_put_contents(
            $file,
            implode("\n", $messageArray),
            FILE_APPEND
        );
    }
1193202
public function log() {
    if (func_num_args() > 0) {
      foreach (func_get_args() as $argument) {
        if (is_array($argument)) echo print_r($argument,true); else echo $argument;
		echo "<br>\n";
      }
    }
  }
901740
function Log($level,$message, $data = "")
	{
		$data = $data != "" ? ": $data" : "";
		switch ($level)
		{
			case DBH_LOG_DEBUG:
				if ($this->LogLevel & DBH_LOG_DEBUG) print "<pre style='color: silver;'>$message</pre>\r\n";
				break;
			case DBH_LOG_INFO:
				if ($this->LogLevel & DBH_LOG_INFO) print "<pre style='color: blue;'>$message $data</pre>\r\n";
				break;
			case DBH_LOG_QUERY:
				if ($this->LogLevel & DBH_LOG_QUERY) print "<pre style='color: green;'>$message $data</pre>\r\n";
				break;
			case DBH_LOG_WARNING:
				if ($this->LogLevel & DBH_LOG_WARNING) print "<pre style='color: orange;'>$message $data</pre>\r\n";
				break;
			case DBH_LOG_ERROR:
				if ($this->LogLevel & DBH_LOG_ERROR) print "<pre style='color: red;'>$message $data</pre>\r\n";
				break;
		}
		
	}
957400
private function writeListing( array $elements, int $indentLevel, string $lineChar ) : void
	{
		if ( 0 === count( $elements ) )
		{
			return;
		}

		$indent = str_repeat( ' ', $indentLevel * 2 );

		$this->write(
			"%s%s %s  \n\n",
			$indent,
			$lineChar,
			implode( "  \n{$indent}{$lineChar} ", $elements )
		);
	}
9933
public function log(array $log)
    {
        if ($this->loggerCallable) {
            call_user_func($this->loggerCallable, array_merge($this->logDefault, $log));
        }
    }
390580
final public void write(char []buf, int offset, int length)
  {
    Writer out = this.out;
    if (out == null)
      return;

    try {
      out.write(buf, offset, length);
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }
  }
711000
private function writeLog($message, array $context, $intLevel)
    {
        $file = $this->getLogLocation($intLevel);
        $verboseDebug = $this->verboseDebugging();

        /**
          The 'logfile' context value just exists for testing
          purposes. Calling code should not rely on this
          behavior 
        */
        if (isset($context['logfile'])) {
            $file = $context['logfile'];
        }
        if (isset($context['verbose'])) {
            $verboseDebug = true;
        }
        if ($file) {
            $fptr = fopen($file, 'a');
            fwrite($fptr, $this->rfcLogLine($message, $intLevel) . "\n");
            if ($this->syslogHost && !isset($context['skip_remote'])) {
                $this->syslogRemote($message);
            }
            if ($intLevel === self::DEBUG && $verboseDebug) {
                $stack = array();
                if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
                    $stack = $this->stackTrace($context['exception']->getTrace());
                } else {
                    $stack = $this->stackTrace(debug_backtrace());
                }
                foreach ($stack as $frame) {
                    fwrite($fptr, $this->rfcLogLine($frame, $intLevel) . "\n");
                }
            }
            fclose($fptr);
        }
    }
471951
@Override
	public void log(Level level, String msg) {
		
		super.log(level, maskPassword(msg));
	}
479490
@Override
	public void log(cn.hutool.log.level.Level level, String format, Object... arguments) {
		log(level, null, format, arguments);
	}