src/Gelembjuk/Logger/FileLogger.php
public function log($level, $message, array $context = array())
	{
		$group = '';
		
		if (isset($context['group'])) {
			$group = $context['group'];
		}
		
		if ($this->groupfilter == '' || $group == '' && $this->groupfilter != 'all') {
			return false;
		}
		
		$logallowed = false;
		
		if ($this->groupfilter == 'all') {
			$logallowed = true;
		} else {
			foreach (explode('|',$group) as $f) {
				if (preg_match('!\\|'.preg_quote($f).'\\|!','|'.$this->groupfilter.'|')) {
					// do log if any path of the filter is allowed to log
					$logallowed = true;
					break;
				}
			}
		}
		
		if (!$logallowed) {
			return false;
		}
		
		if (!$this->extraFilter($level,$context)) {
			return false;
		}
		
		// add log entry to the file
		
		if (is_array($message) || is_object($message)) {
			$message = print_r($message,true);
		}

		$logfilehandle = @fopen($this->logfile,'a');
		
		if (!$logfilehandle) {
			return false;
		}
		
		fwrite($logfilehandle, $this->formatLogLine($message) . "\n");
		
		if (isset($context['extrainfo'])) {
			// log this too
			fwrite($logfilehandle, "\t" . $context['extrainfo'] . "\n");
		}
		
		if ($level == LogLevel::ERROR || 
			$level == LogLevel::CRITICAL ||
			$level == LogLevel::EMERGENCY) {
			
			// maybe logging of trace is needed
			if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
				if ($this->forcelogtrace || $context['forcelogtrace'] === true) {
					fwrite($logfilehandle, $context['exception']->getTraceAsString() . "\n");
				}
			}
		}

		fclose($logfilehandle);
		
		return true;
	}
public function log($level, $message, array $context = array())
	{
		$group = '';
		
		if (isset($context['group'])) {
			$group = $context['group'];
		}
		
		if ($this->groupfilter == '' || $group == '' && $this->groupfilter != 'all') {
			return false;
		}
		
		$logallowed = false;
		
		if ($this->groupfilter == 'all') {
			$logallowed = true;
		} else {
			foreach (explode('|',$group) as $f) {
				if (preg_match('!\\|'.preg_quote($f).'\\|!','|'.$this->groupfilter.'|')) {
					// do log if any path of the filter is allowed to log
					$logallowed = true;
					break;
				}
			}
		}
		
		if (!$logallowed) {
			return false;
		}
		
		if (!$this->extraFilter($level,$context)) {
			return false;
		}
		
		// add log entry to the file
		
		if (is_array($message) || is_object($message)) {
			$message = print_r($message,true);
		}

		$logfilehandle = @fopen($this->logfile,'a');
		
		if (!$logfilehandle) {
			return false;
		}
		
		fwrite($logfilehandle, $this->formatLogLine($message) . "\n");
		
		if (isset($context['extrainfo'])) {
			// log this too
			fwrite($logfilehandle, "\t" . $context['extrainfo'] . "\n");
		}
		
		if ($level == LogLevel::ERROR || 
			$level == LogLevel::CRITICAL ||
			$level == LogLevel::EMERGENCY) {
			
			// maybe logging of trace is needed
			if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
				if ($this->forcelogtrace || $context['forcelogtrace'] === true) {
					fwrite($logfilehandle, $context['exception']->getTraceAsString() . "\n");
				}
			}
		}

		fclose($logfilehandle);
		
		return true;
	}
public function log ( $ level , $ message , array $ context = array ( ) ) { $ group = '' ; if ( isset ( $ context [ 'group' ] ) ) { $ group = $ context [ 'group' ] ; } if ( $ this -> groupfilter == '' || $ group == '' && $ this -> groupfilter != 'all' ) { return false ; } $ logallowed = false ; if ( $ this -> groupfilter == 'all' ) { $ logallowed = true ; } else { foreach ( explode ( '|' , $ group ) as $ f ) { if ( preg_match ( '!\\|' . preg_quote ( $ f ) . '\\|!' , '|' . $ this -> groupfilter . '|' ) ) { // do log if any path of the filter is allowed to log $ logallowed = true ; break ; } } } if ( ! $ logallowed ) { return false ; } if ( ! $ this -> extraFilter ( $ level , $ context ) ) { return false ; } // add log entry to the file if ( is_array ( $ message ) || is_object ( $ message ) ) { $ message = print_r ( $ message , true ) ; } $ logfilehandle = @ fopen ( $ this -> logfile , 'a' ) ; if ( ! $ logfilehandle ) { return false ; } fwrite ( $ logfilehandle , $ this -> formatLogLine ( $ message ) . "\n" ) ; if ( isset ( $ context [ 'extrainfo' ] ) ) { // log this too fwrite ( $ logfilehandle , "\t" . $ context [ 'extrainfo' ] . "\n" ) ; } if ( $ level == LogLevel :: ERROR || $ level == LogLevel :: CRITICAL || $ level == LogLevel :: EMERGENCY ) { // maybe logging of trace is needed if ( isset ( $ context [ 'exception' ] ) && $ context [ 'exception' ] instanceof \ Exception ) { if ( $ this -> forcelogtrace || $ context [ 'forcelogtrace' ] === true ) { fwrite ( $ logfilehandle , $ context [ 'exception' ] -> getTraceAsString ( ) . "\n" ) ; } } } fclose ( $ logfilehandle ) ; return true ; }
The log function. It is not usually called directly. Usually it is better to call other functions from Psr\Log
like debug, error, alert etc

@param int $level This is message level number. Is inherited from Psr\Log
@param string|array|object $message A log message. Can me array or object
@param array $context Contains information about the message. A group of event. It is used to filter messages. Can have other information, like exception

@return boolean to know if a message was logged or not
The log function . It is not usually called directly . Usually it is better to call other functions from Psr \ Log like debug error alert etc