Merges the log array with common log properties.

@param array $log
@return array
429564
protected function mergeLogDefaults(array $log)
    {
        $defaults = [];
        $controls = [];
        if (!empty($this->controls)) {
            foreach ($this->controls as $control) {
                $controls[] = $control->toArray();
            }
        }
        if ($this instanceof CacheableOperationInterface) {
            $defaults['Use Cache'] = var_export($this->getUseCache(), true);
            $defaults['Execute on Cache Miss'] = var_export($this->getExecuteOnCacheMiss(), true);
            $defaults['Invalidate Cache'] = var_export($this->getInvalidateCache(), true);
        }
        $defaults['Server'] = $this->server;
        $defaults['Controls'] = var_export($controls, true);

        return array_merge($log, $defaults);
    }
1162857
private static function format( $log, $show_type = true ) {
			return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['log_type'] . ']' : '' ) . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
		}
746483
protected function mergeRelease(Log $log, $name)
	{
		$myRelease = $this->getRelease($name);
		$theirRelease = $log->getRelease($name);

		$changes = $this->mergeChangesArrays(
			$theirRelease->getAllChanges(),
			$myRelease->getAllChanges()
		);
		$myRelease->setAllChanges($changes);
	}
1026945
public static function from_array( array $log_data ) {

		$defaults = [
			self::MESSAGE => 'Unknown error',
			self::LEVEL   => Logger::DEBUG,
			self::CHANNEL => Channels::DEBUG,
			self::CONTEXT => [],
		];

		$log_level = LogLevel::instance();
		$levels    = Logger::getLevels();

		if ( isset( $log_data[ self::LEVEL ] ) && is_string( $log_data[ self::LEVEL ] ) ) {
			$log_data[ self::LEVEL ] = $log_level->check_level( $log_data[ self::LEVEL ], $levels );
		}

		$log_data = array_filter( filter_var_array( $log_data, self::$filters ) );

		$data = array_merge( $defaults, $log_data );

		return new static(
			$data[ self::MESSAGE ],
			$data[ self::LEVEL ],
			$data[ self::CHANNEL ],
			$data[ self::CONTEXT ]
		);
	}
805281
public function log(array $log)
    {
        $log['db'] = $this->database->getName();
        $log['collection'] = $this->getName();
        call_user_func($this->loggerCallable, $log);
    }
824937
protected function processLogs($logs)
	{
		$text='';
		foreach($logs as $log)
			$text.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);

		$logFile=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile();
		$fp=@fopen($logFile,'a');
		@flock($fp,LOCK_EX);
		if(@filesize($logFile)>$this->getMaxFileSize()*1024)
		{
			$this->rotateFiles();
			@flock($fp,LOCK_UN);
			@fclose($fp);
			@file_put_contents($logFile,$text,FILE_APPEND|LOCK_EX);
		}
		else
		{
			@fwrite($fp,$text);
			@flock($fp,LOCK_UN);
			@fclose($fp);
		}
	}
499133
function setLog($log) {
		if (!$log) {
			$this->logFile = null;
			$this->logCallback = null;
		} elseif (is_callable($log)) {
			$this->logFile = null;
			$this->logCallback = $log;
		} else {
			Files::create($log);
			$this->logFile = $log;
			$this->logCallback = null;
		}
		return $this;
	}
1032202
protected function mergeTrees(array $trees): array
    {
        if (count($trees) == 0) {
            return [];
        }

        $tree1 = array_shift($trees);
        while (count($trees)) {
            $tree2 = array_shift($trees);
            foreach ($tree2 as $key => $value) {
                if (in_array($key, $this->permissionKeys)) {
                    $tree1 = $tree2;
                    break;
                }
                if (isset($tree1[$key]) && is_array($value)) {
                    $tree1[$key] = $this->mergeTrees([$tree1[$key], $tree2[$key]]);
                    continue;
                }
                $tree1[$key] = $value;
            }
        }

        return $tree1;
    }
388094
public function log(array $log)
    {
        $log['db'] = $this->database->getName();
        $log['collection'] = $this->getName();
        call_user_func_array($this->loggerCallable, array($log));
    }
594356
protected function _reportDiff($log)
    {
        $data = $log->data();

        $this->write("It expect actual ");

        if ($log->not()) {
            $this->write('NOT ', 'cyan');
            $not = 'not ';
        } else {
            $not = '';
        }
        $this->write("to {$log->description()}\n\n");

        foreach ($data as $key => $value) {
            if (preg_match('~actual~', $key)) {
                $this->write("{$key}:\n", 'yellow');
                $this->prefix($this->format(' ', 'n;;91') . ' ');
            } elseif (preg_match('~expected~', $key)) {
                $this->write("{$not}{$key}:\n", 'yellow');
                $this->prefix($this->format(' ', 'n;;92') . ' ');
            } else {
                $this->write("{$key}:\n", 'yellow');
            }
            $type = gettype($value);
            $toString = function ($instance) {
                return 'an instance of `' . get_class($instance) . '`';
            };
            $this->write("({$type}) " . Text::toString($value, ['object' => ['method' => $toString]]));
            $this->prefix('');
            $this->write("\n");
        }
        $this->write("\n");
    }
1313353
public function addLog(Log $log)
    {
        $log->setInstance($this);
        $this->getLogs()->add($log);
    }
494861
public function col_indicators($log) {
        $indicatorclasses = json_decode($log->indicators);
        $indicators = array();
        foreach ($indicatorclasses as $indicatorclass) {
            $indicator = \core_analytics\manager::get_indicator($indicatorclass);
            if ($indicator) {
                $indicators[] = $indicator->get_name();
            } else {
                debugging('Can\'t load ' . $indicatorclass . ' indicator', DEBUG_DEVELOPER);
            }
        }
        return '<ul><li>' . implode('</li><li>', $indicators) . '</li></ul>';
    }
22481
public function trim($log)
    {
        $period = new \DateTime('-7 day');
        if ($log === 'change') {
            $this->changeRepository->trimLog($period);
        } elseif ($log === 'system') {
            $this->systemRepository->trimLog($period);
        } else {
            throw new \UnexpectedValueException("Invalid log type requested: $log");
        }
    }
742365
public function log(array $log)
    {
        if (null !== $this->config->getLoggerCallable()) {
            call_user_func($this->config->getLoggerCallable(), $log);
        }
    }
1334827
protected function getLogPath($log)
    {

        $dir = $this->log_root.'/'.$log.'/';

        if(!is_dir($dir)){
            mkdir($dir, 0777, true);
        }

        return $dir;
    }
230210
public function formatLog(array $logMessage) {
        extract($logMessage);

        $level = strtoupper($level);
        $message = $this->applyContext($message, $context);
        $timestamp = date($this->dateTimeFormat, $timestamp);
        $exception = $this->getExceptionTrace($context);

        $log = str_replace(self::FORMAT_TIMESTAMP, $timestamp, $this->logFormat);
        $log = str_replace(self::FORMAT_LEVEL, $level, $log);
        $log = str_replace(self::FORMAT_MESSAGE, $message, $log);
        $log = str_replace(self::FORMAT_EXCEPTION, $exception, $log);

        return $log;
    }
861780
protected function initLog( array $config )
    {
        if ( isset( $config[ 'log' ] ) )
        {
            if ( isset( $config[ 'log' ][ 'class' ] ) )
            {
                $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config )
                {
                    $class = $config[ 'log' ][ 'class' ];

                    return new $class( $config[ 'log' ] );
                }
                );
            }
            else
            {
                $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config )
                {
                    return new Log( $config[ 'log' ] );
                }
                );
            }
        }
        else
        {
            $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function ()
            {
                return new Log();
            }
            );
        }

        $this->alias( 'RawPHP\RawLog\Contract\ILog', 'log' );
    }