Create a log and associates it to a user

@param $logMessage
@param $userTarget
437638
public function TargettedLog($logMessage, $userTarget)
    {
        $log = $this->getLogsRepository()->create(['log' => $logMessage, 'target' => $userTarget, 'ip' => Request::ip()]);
    }
1069376
public function logMessage(Message $message) {
        foreach($this->logger as $logger) {
            $logger->logMessage($message);
        }
    }
99560
public static function log(LoggerInterface $logger = null, $message, $context = [])
    {
        if ($logger) {
            $logger->warning($message, $context);
        } else {
            $replace = [];
            foreach ($context as $k => $v) {
                if (is_scalar($v)) {
                    $replace['{'.$k.'}'] = $v;
                }
            }
            @trigger_error(strtr($message, $replace), E_USER_WARNING);
        }
    }
927602
private function logMessage(
        LoggerInterface $logger,
        string $level,
        string $value
    ) {
        /**
         * Logs content, using specified level.
         */
        $logger->$level($value);
    }
1201105
protected function _afterLogin(array $userData, &$targetUrl) {
        if ($loginHelper = $this->_getLoginHelper()) {
            $loginHelper->afterLogin($userData, $targetUrl);
        }
    }
1194422
public function processKick(UserEvent $event, Queue $queue)
    {
        $logger = $this->getLogger();

        $server = strtolower($event->getConnection()->getServerHostname());
        $params = $event->getParams();
        $channel = $params['channel'];
        $nick = $params['user'];
        $message = isset($params['comment']) ? $params['comment'] : null;

        if ($nick == $event->getConnection()->getNickname()) {
            $logger->debug('Removing channel', array('server' => $server, 'channel' => $channel));
            unset($this->channels[$server][$channel]);
            return;
        }

        $logger->debug('Processing incoming KICK', array(
            'server' => $server,
            'channel' => $channel,
            'nick' => $nick,
            'message' => $message,
        ));

        unset($this->channels[$server][$channel][$nick]);

        try {
            $this->db->fetchAssoc(self::SQL_UPDATE, array(
                ':time' => time(),
                ':server' => $server,
                ':channel' => $channel,
                ':nick' => $nick,
                ':type' => self::TYPE_KICK,
                ':text' => $message,
            ));
        } catch (\Exception $e) {
            $logger->error($e->getMessage());
        }
    }
779410
public function onPostUpdate(UserEvent $event)
    {
        if (!$event->hasData('password')) {
            return;
        }

        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $user = $event->getResource();

        if (0 < $this->mailer->sendNewPasswordEmailMessage($user, $event->getData('password'))) {
            $event->addMessage(new ResourceMessage('ekyna_user.user.event.credentials_sent'));
        }
    }
343739
protected function createMessageCallback(Recipient $user, $subject = null, $callback = null)
    {
        return function (Message $message) use ($user, $subject, $callback) {
            // Set the recipient detail.
            $message->to($user->getRecipientEmail(), $user->getRecipientName());

            // Only append the subject if it was provided.
            ! empty($subject) && $message->subject($subject);

            // Run any callback if provided.
            \is_callable($callback) && $callback(...func_get_args());
        };
    }
1160523
protected function queueRecallerCookie(UserContract $user)
    {
        $value = $user->getAuthIdentifier() . '|' . $user->getRememberToken();

        $this->getCookieJar()->queue($this->createRecaller($value));
    }
435322
public static function createFrom(
        Storage $persistenceProvider,
        Storage $cacheProvider,
        LoggerInterface $logger = null
    ) {
        /** @var $userAgentHandlerChain \Wurfl\Handlers\Chain\UserAgentHandlerChain */
        $userAgentHandlerChain = $cacheProvider->load('UserAgentHandlerChain');

        if (!($userAgentHandlerChain instanceof UserAgentHandlerChain)) {
            $userAgentHandlerChain = self::init();
            $cacheProvider->save('UserAgentHandlerChain', $userAgentHandlerChain, 3600);
        }

        $userAgentHandlerChain->setLogger($logger);

        foreach ($userAgentHandlerChain->getHandlers() as $handler) {
            /* @var $handler \Wurfl\Handlers\AbstractHandler */
            $handler
                ->setLogger($logger)
                ->setPersistenceProvider($persistenceProvider);
        }

        return $userAgentHandlerChain;
    }
1104036
public function logMessage(Message $message): void
    {
        if (in_array($message->getLevel(), $this->config['log'])) {
            if ($this->config['send_immediately']) {

                call_user_func($this->config['exec'], $message);

            } else {
                $this->messages[] = $message;

                if (count($this->messages) == 1) {
                    // register shutdown on first message in queue
                    $self = $this;
                    register_shutdown_function(function () use ($self) {
                        $fn = $self->getExecFunction();
                        call_user_func($fn, $self->getMessages());
                    });
                }
            }
        }
    }
1015406
public static function mark_message_as_read($userid, $message, $timeread = null) {
        global $DB;

        if (is_null($timeread)) {
            $timeread = time();
        }

        $mua = new \stdClass();
        $mua->userid = $userid;
        $mua->messageid = $message->id;
        $mua->action = self::MESSAGE_ACTION_READ;
        $mua->timecreated = $timeread;
        $mua->id = $DB->insert_record('message_user_actions', $mua);

        // Get the context for the user who received the message.
        $context = \context_user::instance($userid, IGNORE_MISSING);
        // If the user no longer exists the context value will be false, in this case use the system context.
        if ($context === false) {
            $context = \context_system::instance();
        }

        // Trigger event for reading a message.
        $event = \core\event\message_viewed::create(array(
            'objectid' => $mua->id,
            'userid' => $userid, // Using the user who read the message as they are the ones performing the action.
            'context' => $context,
            'relateduserid' => $message->useridfrom,
            'other' => array(
                'messageid' => $message->id
            )
        ));
        $event->trigger();
    }
1100753
public function create_message($userName, $subject, $textBody, $action = null, $pmId = null)
    {
        try {
            $manager = $this->container->get('symbb.extension.tapatalk.manager.user');
            return $manager->createMessage($userName, $subject, $textBody, $action, $pmId);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc);
        }
    }
1122304
protected static function evaluateTarget(
        ContextInterface $context,
        array $target,
        ?LoggerInterface $logger
    ): int {
        /** @see http://docs.oasis-open.org/xacml/3.0/xacml-3.0-core-spec-os-en.html #7.11 (table 4) */

        assert(Encoder::isTarget($target) === true);

        $anyOfs = Encoder::targetAnyOfs($target);
        $name   = $logger === null ? null : Encoder::targetName($target);

        if ($anyOfs === null) {
            $logger === null ?: $logger->debug("Target '$name' matches anything.");

            return TargetMatchEnum::NO_TARGET;
        }

        $result = TargetMatchEnum::NOT_MATCH;
        foreach ($anyOfs as $allOfs) {
            try {
                $isAllOfApplicable = true;
                foreach ($allOfs as $key => $value) {
                    if ($context->has($key) === false || $context->get($key) !== $value) {
                        $isAllOfApplicable = false;
                        break;
                    }
                }
                if ($isAllOfApplicable === true) {
                    $logger === null ?: $logger->debug("Target '$name' matches.");

                    return TargetMatchEnum::MATCH;
                }
            } catch (RuntimeException $exception) {
                $logger === null ?: $logger->warning("Target '$name' got exception from context for its properties.");
                $result = TargetMatchEnum::INDETERMINATE;
            }
        }

        $logger === null ?: $logger->debug("Target '$name' has no match.");

        return $result;
    }
433704
private function applyDecorators(LoggerInterface $logger, array $config)
    {
        foreach ($this->decorators as $configKey => $decoratorClassName) {
            if (!isset($config[$configKey])) {
                continue;
            }
            if (!class_exists($decoratorClassName)) {
                throw new \RuntimeException('Decorator class not found: ' . $decoratorClassName);
            }
            if (!is_subclass_of($decoratorClassName, '\Phlib\Logger\Decorator\AbstractDecorator')) {
                throw new \RuntimeException('Decorator class invalid: ' . $decoratorClassName);
            }
            /** @var \Phlib\Logger\Decorator\AbstractDecorator $logger */
            $logger = new $decoratorClassName($logger, $config[$configKey]);
        }

        return $logger;
    }
1200810
def log(self, user, content, message):
        
        return self.create(
            user=user,
            content_type=ContentType.objects.get_for_model(content),
            object_id=content.pk,
            change_message=message
        )
81177
public static function userCanOnLogs( $log , $action , $value , $username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();
		if ( is_null( $username ) ) return false;
		if ( ! self::userExists( $username ) ) return false;
		if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
		if ( ! isset( self::$auth['users'][ $username ]['logs'][ $log ][ $action ] ) ) return false;
		return ( self::$auth['users'][ $username ]['logs'][ $log ][ $action ] === $value );
	}