Create a log

@param $logMessage
495054
public function Log($logMessage)
    {
        $target = null;

        if ($user = Sentinel::getUser())
            if ($user != null)
                $target = $user->id;

        $log = $this->getLogsRepository()->create(['log' => $logMessage, 'ip' => Request::ip(), 'target' => $target]);
    }
892805
public function log($message)
    {
        $formattedMessage = $this->formatMessage($message);
        if (!empty($formattedMessage)) {
            $this->logger->info($formattedMessage);
        }
    }
911385
private function logToFile($message) {
		if($this->logpath != '') {
			$logfile = fopen($this->logpath, "a");
			if($logfile) {
				fwrite($logfile, $message);
				fclose($logfile);
			}
		}
	}
1335361
protected function logLine($messageType, $messageText)
    {
        switch ($messageType) {
            case Process::ERR:
                $typeStr = "[Error]";
                break;
            default:
                $typeStr = "";
                break;
        }

        echo sprintf("\n%s %s\n", $typeStr, $messageText);
    }
820652
public static function create(LoggerInterface $logger, array $options = [])
    {
        $context = new \ZMQContext();
        $socket = $context->getSocket(\ZMQ::SOCKET_REQ);
        $socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, $options['linger']);
        $socket->connect(sprintf(
            '%s://%s:%s', $options['protocol'], $options['host'], $options['port']
        ));

        return new static($socket, $logger);
    }
1031765
public function onLog(LogGenericEvent $event)
    {
        $log = null;
        $logCreated = false;

        if (!($event instanceof LogNotRepeatableInterface) || !$this->isARepeat($event)) {
            $log = $this->createLog($event);
            $logCreated = true;
        }

        // Increment view count
        if ($event instanceof LogResourceReadEvent) {
            // Get connected user
            $tokenStorage = $this->container->get('security.token_storage');
            $token = $tokenStorage->getToken();
            $user = $token ? $token->getUser() : null;

            // Increment view count if viewer is not creator of the resource
            if (is_null($user) || is_string($user) || $user !== $event->getResource()->getCreator()) {
                // TODO : add me in an event on the resource 'open'
                $this->resourceManager->addView($event->getResource());
            }
            if ($logCreated && !empty($user) && 'anon.' !== $user && 'directory' !== $event->getResource()->getResourceType()->getName()) {
                $this->resourceEvalManager->updateResourceUserEvaluationData(
                    $event->getResource(),
                    $user,
                    new \DateTime(),
                    ['status' => AbstractResourceEvaluation::STATUS_OPENED],
                    ['status' => true],
                    false
                );
            }
        }
        if ($logCreated && $log && (
            $event instanceof LogUserLoginEvent ||
            $event instanceof LogWorkspaceEnterEvent ||
            $event instanceof LogResourceReadEvent ||
            $event instanceof LogWorkspaceToolReadEvent ||
            $event instanceof LogDesktopToolReadEvent ||
            $event instanceof LogAdminToolReadEvent
        )) {
            $this->logConnectManager->manageConnection($log);
        }
    }
681829
public function logError(ContactEventLog $eventLog, $errorMessage)
    {
        // @todo - add translator for messages.
        $eventLog->addProperty('error', $errorMessage)
            ->setAction('failed');
        $this->ContactEventLogRepo->saveEntity($eventLog);
        // $this->logDebug('Line '. 1 .' error: '.'err', []);
    }
70339
public function onLogEvent(LogEvent $event)
    {
        $context = $event->getContext();
        $context['event.name'] = $event->getEventNameContext();

        $eventSubscriberClassName = get_class($event->getEventSubscriberContext());
        if (strrpos($eventSubscriberClassName, '\\') !== false) {
            $eventSubscriberClassName = substr($eventSubscriberClassName, strrpos($eventSubscriberClassName, '\\') + 1);
        }
        $context['event.task.name'] = $eventSubscriberClassName;

        $this->logger->log($event->getLevel(), $event->getMessage(), $context);
    }
939769
public static function debug($msg = 'test')
    {
        try {
            if (function_exists('log_message')) {
                log_message('debug', $msg);
            } else {
                if (self::USE_DEBUG === TRUE) {
                    $logger = new Logger('imageCache');
                    $logger->pushHandler(new StreamHandler(__DIR__ . '/../storage/logs/Log-' . date('Y-m-d') . '.log', Logger::DEBUG));
                    $logger->debug($msg);
                }
            }
        }
        catch (\Exception $e) {
            if (function_exists('log_message')) {
                $message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
                log_message('error', $message);
            }

            return;
        }
    }
1069376
public function logMessage(Message $message) {
        foreach($this->logger as $logger) {
            $logger->logMessage($message);
        }
    }
1191408
public function log($msg)
    {
        $backtrace = debug_backtrace();
        if (!isset($backtrace[1]['function'])) {
            return;
        }

        $i = 1;
        $stackSize = count($backtrace);
        do {
            $callingMethod = $backtrace[$i]['function'];
            $i++;
        } while ($callingMethod == "log" && $i < $stackSize);

        if (!$msg || !$this->isLogEnabledForMethod($callingMethod)) {
            return;
        }

        $this->getLogger()->info($msg);
    }
670845
public function logMessage() {
        if (is_null($this->options['logger'])) {
            return;
        }
        $arguments = func_get_args();
        $severity = array_shift($arguments);
        $format = array_shift($arguments);
        call_user_func_array($this->options['logger'], [$severity, vsprintf($format, $arguments)]);
    }
762151
public static function log($msg)
    {
        if (!self::$_enabled) {
            return;
        }

        if (is_null(self::$_file)) {
            echo "log: $msg\n";
            return;
        }

        return self::_logToFile($msg);
    }
402626
public static function makeLog($message, array $context = [], array $params = [])
    {
        self::init($params);
        self::$instance->makeLog($message, $context);
    }
532917
public function msg($msg)
    {
        $this->log .= date('Y-m-d H:i:s') . ' ' . $msg . "\n";

        if (php_sapi_name() === 'cli') {
            $this->cli->line($msg);
        } else {
            echo $msg . "<br/>\n";
        }
    }
812694
protected function createLogger(string $loggerName)
  {
    # Create the Logger Object
    $this->logger = new \Nofuzz\Log\Logger($loggerName);

    # Get the conf options
    $logLevel = $this->getConfig()->get('log.level','error');
    $logDriver = $this->getConfig()->get('log.driver','file');

    $logDateFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_datetime','Y-m-d H:i:s');
    $logLineFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_format','%datetime% > %level_name% > %message% %context% %extra%');

    if ( strcasecmp($logDriver,"file")==0 ) {
      $logFilePath = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_path','storage/log');
      $logFileFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_format','Y-m-d');
      # Create the Log Handler
      $handler = new \Monolog\Handler\StreamHandler(
        realpath($this->basePath.'/'.$logFilePath).'/'.date($logFileFormat).'.log',
        $this->getLogger()->toMonologLevel($logLevel)
      );

    } else if ( strcasecmp($logDriver,"php")==0 ) {
      # Create the Log Handler
      $handler = new \Monolog\Handler\ErrorLogHandler (
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        $this->getLogger()->toMonologLevel($logLevel)
      );

    }
    # finally, create a formatter for it
    $formatter = new \Monolog\Formatter\LineFormatter($logLineFormat, $logDateFormat);
    $handler->setFormatter($formatter);

    # Push the handler to the logger
    $this->logger->pushHandler($handler);

    # Set our own error handlers
    $this->setErrorHandlers();

    return $this;
  }
564066
private static function _writeLog($filename, $msg, $addTime = true)
    {
        // preppend details
        if($addTime) {
            $msg = self::formatHeaderWithTime() . $msg;
        }

        if(DI::has('BufferOptions')) {

            $options = DI::get('BufferConnectionOptions');

            $callback = function($data) use ($filename) {
                Writer::writeLogVerbose($filename, implode("\n\n", $data) . "\n\n");
            };

            // just to be on safe side, set max size to 500, that is reasonable number
            $maxSize = 500;

            $size = isset($options['size']) && is_int($options['size']) && $options['size'] > 0 && $options['size'] < $maxSize
                ? $options['size']
                : $maxSize;

            $buffer = new Buffer($filename, Buffer::ADAPTER_REDIS, $size, $callback, $options);
            $buffer->add($msg);

        } else {
            Writer::writeLogVerbose($filename, $msg);
        }
    }