src/Log/Engine/DatabaseLog.php
public function log($level, $message, array $context = []) {

        if ( $this->config('requiredScope') && ( empty($context['scope']) ) )
            return false;

        $scopes = ( empty($context['scope']) ) ? [null] : $context['scope'];
        unset($context['scope']);
        $this->_context = $context;

        $Table = TableRegistry::get($this->config('model'), ['table' => $this->config('table')]);

        foreach ( $scopes as $scope ) {
            $entity = $Table->newEntity();

            $data = [
                'level'   => $level,
                'user_id' => $this->_userId(),
                'scope'   => $scope,
                'message' => $message,
                'context' => $this->_context,
            ];

            $entity = $Table->patchEntity($entity, $data);

            $Table->save($entity);
        }

        return true;
    }
public function log($level, $message, array $context = []) {

        if ( $this->config('requiredScope') && ( empty($context['scope']) ) )
            return false;

        $scopes = ( empty($context['scope']) ) ? [null] : $context['scope'];
        unset($context['scope']);
        $this->_context = $context;

        $Table = TableRegistry::get($this->config('model'), ['table' => $this->config('table')]);

        foreach ( $scopes as $scope ) {
            $entity = $Table->newEntity();

            $data = [
                'level'   => $level,
                'user_id' => $this->_userId(),
                'scope'   => $scope,
                'message' => $message,
                'context' => $this->_context,
            ];

            $entity = $Table->patchEntity($entity, $data);

            $Table->save($entity);
        }

        return true;
    }
Implements writing to log files.

@param string $level The severity level of the message being written.
See Cake\Log\Log::$_levels for list of possible levels.
@param string $message The message you want to log.
@param array $context Additional information about the logged message
@return bool success of write.