Prepare log event log event.

@param logEvent the log event
@return the log event
762356
public static LogEvent prepareLogEvent(final LogEvent logEvent) {
        val messageModified = TicketIdSanitizationUtils.sanitize(logEvent.getMessage().getFormattedMessage());
        val message = new SimpleMessage(messageModified);
        val newLogEventBuilder = Log4jLogEvent.newBuilder()
            .setLevel(logEvent.getLevel())
            .setLoggerName(logEvent.getLoggerName())
            .setLoggerFqcn(logEvent.getLoggerFqcn())
            .setContextData(new SortedArrayStringMap(logEvent.getContextData()))
            .setContextStack(logEvent.getContextStack())
            .setEndOfBatch(logEvent.isEndOfBatch())
            .setIncludeLocation(logEvent.isIncludeLocation())
            .setMarker(logEvent.getMarker())
            .setMessage(message)
            .setNanoTime(logEvent.getNanoTime())
            .setThreadName(logEvent.getThreadName())
            .setThrownProxy(logEvent.getThrownProxy())
            .setThrown(logEvent.getThrown())
            .setTimeMillis(logEvent.getTimeMillis());

        try {
            newLogEventBuilder.setSource(logEvent.getSource());
        } catch (final Exception e) {
            newLogEventBuilder.setSource(null);
        }
        return newLogEventBuilder.build();
    }
1211343
protected EventBuilder createEventBuilder(LogEvent event) {
        Message eventMessage = event.getMessage();
        EventBuilder eventBuilder = new EventBuilder()
            .withSdkIntegration("log4j2")
            .withTimestamp(new Date(event.getTimeMillis()))
            .withMessage(eventMessage.getFormattedMessage())
            .withLogger(event.getLoggerName())
            .withLevel(formatLevel(event.getLevel()))
            .withExtra(THREAD_NAME, event.getThreadName());

        if (eventMessage.getFormat() != null
            && !eventMessage.getFormat().equals("")
            && !eventMessage.getFormattedMessage().equals(eventMessage.getFormat())) {
            eventBuilder.withSentryInterface(new MessageInterface(
                eventMessage.getFormat(),
                formatMessageParameters(eventMessage.getParameters()),
                eventMessage.getFormattedMessage()));
        }

        Throwable throwable = event.getThrown();
        if (throwable != null) {
            eventBuilder.withSentryInterface(new ExceptionInterface(throwable));
        } else if (event.getSource() != null) {
            StackTraceElement[] stackTrace = {event.getSource()};
            eventBuilder.withSentryInterface(new StackTraceInterface(stackTrace));
        }

        if (event.getContextStack() != null) {
            eventBuilder.withExtra(LOG4J_NDC, event.getContextStack().asList());
        }

        if (event.getContextMap() != null) {
            for (Map.Entry<String, String> contextEntry : event.getContextMap().entrySet()) {
                if (Sentry.getStoredClient().getMdcTags().contains(contextEntry.getKey())) {
                    eventBuilder.withTag(contextEntry.getKey(), contextEntry.getValue());
                } else {
                    eventBuilder.withExtra(contextEntry.getKey(), contextEntry.getValue());
                }
            }
        }

        if (event.getMarker() != null) {
            eventBuilder.withTag(LOG4J_MARKER, event.getMarker().getName());
        }

        return eventBuilder;
    }
804458
@Override
	public void prepare() {
		List<Log> logs = global.logs();
		Object parent = null;
		
		for (int i = logs.size() - 1; i >=0; i--) {
			if (logs.get(i).operation() != Log.Operation.GET) {
				parent = logs.get(i).entity();
				break;
			}
		}
		
		Lock lock = new Lock(global.id(), KeyFactory.createKeyString(
				Keys.create(Translation.toKind(parent.getClass()), Entities.keyValue(parent)), 
				Translation.TRANSACTION_KIND, 
				global.id()), new Date());
		datastore.put(local, Translation.toEntity(lock, Keys.create(
				Translation.toKind(entity.getClass()), Entities.keyValue(entity))));
		local.commit();
		this.lock = lock;
	}
783473
function(loggingEvent) {
		var useragent = "unknown";
		try {
			useragent = navigator.userAgent;
		} catch(e){
			useragent = "unknown";
		}
		
		var referer = "unknown";
		try {
			referer = location.href;
		} catch(e){
			referer = "unknown";
		}
				
		var content = "<log4js:event logger=\"";
		content += loggingEvent.categoryName + "\" level=\"";
		content += loggingEvent.level.toString() + "\" useragent=\"";
		content += useragent + "\" referer=\"";
		content += referer.replace(/&/g, "&amp;") + "\" timestamp=\"";
		content += loggingEvent.getFormattedTimestamp() + "\">\n";
		content += "\t<log4js:message><![CDATA[" + this.escapeCdata(loggingEvent.message) + "]]></log4js:message>\n";	
 		
 		if (loggingEvent.exception) {
			content += this.formatException(loggingEvent.exception) ;
		}
 		content += "</log4js:event>\n";
        
      return content;
	}
1289255
public function beforeLog(Event $event, array $logs)
    {
        foreach ($logs as $log) {
            $log->setMetaInfo($log->getMetaInfo() + $this->data);
        }
    }
1279253
@Override
	@SuppressWarnings({ "unchecked" })
	protected void append(final LoggingEvent event) {
		if (null == this.client) {
			try {
				connectToAerospike();
			} catch (UnknownHostException e) {
				throw new RuntimeException(e.getMessage(), e);
			}
		}
		List<Bin> binList = new ArrayList<Bin>();
		StringBuilder keyString = new StringBuilder();
		if (null != applicationId) {
			MDC.put(APP_ID, applicationId);
			keyString.append(applicationId).append(":");
			binList.add(new Bin(APP_ID, applicationId));
		}
		String eventName = event.getLogger().getName();
		binList.add(new Bin(NAME, eventName));
		keyString.append(eventName).append(":");
		binList.add(new Bin(LEVEL, event.getLevel().toString()));
		keyString.append(event.getLevel().toString()).append(":");
		Calendar tstamp = Calendar.getInstance();
		tstamp.setTimeInMillis(event.getTimeStamp());
		binList.add(new Bin(TIMESTAMP, event.getTimeStamp()));
		keyString.append(event.getTimeStamp());
		
		// Copy properties into the record
		Map<Object, Object> props = event.getProperties();
		if (null != props && props.size() > 0) {
			Map<String, String> propsMap = new HashMap<String, String>();
			for (Map.Entry<Object, Object> entry : props.entrySet()) {
				propsMap.put(entry.getKey().toString(), entry.getValue().toString());
			}
			binList.add(new Bin(PROPERTIES, propsMap));
		}

		// Copy traceback info (if there is any) into the record
		String[] traceback = event.getThrowableStrRep();
		if (null != traceback && traceback.length > 0) {
			List<String> tb = new ArrayList<String>();
			tb.addAll(Arrays.asList(traceback));
			binList.add(new Bin(TRACEBACK, tb));
		}

		// Put the rendered message into the record
		binList.add(new Bin(MESSAGE, event.getRenderedMessage()));

		// Insert a record
		Calendar now = Calendar.getInstance();
		MDC.put(YEAR, now.get(Calendar.YEAR));
		MDC.put(MONTH, String.format("%1$02d", now.get(Calendar.MONTH) + 1));
		MDC.put(DAY, String.format("%1$02d", now.get(Calendar.DAY_OF_MONTH)));
		MDC.put(HOUR, String.format("%1$02d", now.get(Calendar.HOUR_OF_DAY)));

		MDC.remove(YEAR);
		MDC.remove(MONTH);
		MDC.remove(DAY);
		MDC.remove(HOUR);
		if (null != applicationId) {
			MDC.remove(APP_ID);
		}
		Key key = new Key(this.namespace, this.set, keyString.toString());
		this.client.put(null, key, binList.toArray(new Bin[0]));
	}
902413
private void logEvent(Node node, EventType eventType)
    {
        // Node contains original as well as transactional copy.
        EventLog log = new EventLog(eventType, node);
        eventLogQueue.onEvent(log, eventType);
    }
828788
public function onLog(LogCreateEvent $event)
    {
        $log = $event->getLog();
        $dateLog = $log->getDateLog();
        $action = $log->getAction();
        $resourceNode = $log->getResourceNode();
        $user =  $log->getDoer();

        if (!is_null($user)) {
            $activityRules = is_null($resourceNode) ?
                $this->activityManager
                    ->getActivityRuleByActionWithNoResource($action) :
                $this->activityManager
                    ->getActivityRuleByActionAndResource($action, $resourceNode);

            if (count($activityRules) > 0) {
                foreach ($activityRules as $activityRule) {
                    $activityParams = $activityRule->getActivityParameters();
                    $accessFrom = $activityRule->getActiveFrom();
                    $accessUntil = $activityRule->getActiveUntil();

                    if ((is_null($accessFrom) || $dateLog >= $accessFrom)
                        && (is_null($accessUntil) || $dateLog <= $accessUntil)) {
                        $nbRules = is_null($activityParams->getRules()) ?
                            0 :
                            count($activityParams->getRules());

                        if ($nbRules > 0) {
                            $rules = $activityParams->getRules();
                            $ruleType = 'result';

                            foreach ($rules as $rule) {
                                if (is_null($rule->getResult())) {
                                    $ruleType = 'occurrence';
                                    break;
                                }
                            }

                            $rulesLogs = $this->ruleValidator->validate($activityParams, $user);

                            if (isset($rulesLogs['validRules'])
                                && $rulesLogs['validRules'] >= $nbRules) {
                                $activityStatus = $ruleType === 'occurrence' ?
                                    AbstractEvaluation::STATUS_COMPLETED :
                                    AbstractEvaluation::STATUS_PASSED;
                            } else {
                                $activityStatus = $ruleType === 'occurrence' ?
                                    AbstractEvaluation::STATUS_INCOMPLETE :
                                    AbstractEvaluation::STATUS_FAILED;
                            }

                            $this->activityManager->manageEvaluation(
                                $user,
                                $activityParams,
                                $log,
                                $rulesLogs,
                                $activityStatus
                            );
                        }
                    }
                }
            }
        }
    }
403190
public static LogPosition createPosition(Event event) {
        EntryPosition position = new EntryPosition();
        position.setJournalName(event.getJournalName());
        position.setPosition(event.getPosition());
        position.setTimestamp(event.getExecuteTime());
        // add serverId at 2016-06-28
        position.setServerId(event.getServerId());
        // add gtid
        position.setGtid(event.getGtid());

        LogPosition logPosition = new LogPosition();
        logPosition.setPostion(position);
        logPosition.setIdentity(event.getLogIdentity());
        return logPosition;
    }
183093
public boolean logEvent(Context context) {
        boolean isReqQueued = false;
        String reqPath = isStandardEvent ? Defines.RequestPath.TrackStandardEvent.getPath() : Defines.RequestPath.TrackCustomEvent.getPath();
        if (Branch.getInstance() != null) {
            Branch.getInstance().handleNewRequest(new ServerRequestLogEvent(context, reqPath));
            isReqQueued = true;
        }
        return isReqQueued;
    }
23248
def create_log(self):
        """"""
        return EventLog(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
941902
public synchronized void dispatchEvent(LogRecord event) {
        if (binaryHandler == null || 
        	((textHandler == null && logRepositoryConfiguration.isTextEnabled()) || 
        	(textHandler != null && !logRepositoryConfiguration.isTextEnabled()))) {
            determineHandlers();
        }
        if (binaryHandler == null)	{ 	// Either doing LogManager Reset, or major issue occurring 666241.1
        	return ;
        } else {
            binaryHandler.publish(event);
        }
        if (textHandler != null) {
            textHandler.publish(event);
        }
    }
482510
private LoggingEvent buildEvent() {
    if (currentMap.size() == 0) {
      if (additionalLines.size() > 0) {
        for (Iterator iter = additionalLines.iterator();iter.hasNext();) {
          getLogger().info("found non-matching line: " + iter.next());
        }
      }
      additionalLines.clear();
      return null;
    }
    //the current map contains fields - build an event
    int exceptionLine = getExceptionLine();
    String[] exception = buildException(exceptionLine);

    //messages are listed before exceptions in additionallines
    if (additionalLines.size() > 0 && exception.length > 0) {
      currentMap.put(MESSAGE, buildMessage((String) currentMap.get(MESSAGE),
          exceptionLine));
    }
    LoggingEvent event = convertToEvent(currentMap, exception);
    currentMap.clear();
    additionalLines.clear();
    return event;
  }
750127
public void addEvent(LogEvent event) {
        try {
            write(getString(event));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
574113
protected void logEvent(FaxClientSpiProxyEventType eventType,Method method,Object[] arguments,Object output,Throwable throwable)
    {
        //init log data
        int amount=3;
        int argumentsAmount=0;
        if(arguments!=null)
        {
            argumentsAmount=arguments.length;
        }
        if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE)
        {
            amount=amount+2;
        }
        Object[] logData=new Object[amount+argumentsAmount];
        
        //set log data values
        switch(eventType)
        {
            case PRE_EVENT_TYPE:
                logData[0]="Invoking ";
                break;
            case POST_EVENT_TYPE:
                logData[0]="Invoked ";
                break;
            case ERROR_EVENT_TYPE:
                logData[0]="Error while invoking ";
                break;
        }
        logData[1]=method.getName();
        if(argumentsAmount>0)
        {
            logData[2]=" with data: ";
            System.arraycopy(arguments,0,logData,3,argumentsAmount);
        }
        else
        {
            logData[2]="";
        }
        if(eventType==FaxClientSpiProxyEventType.POST_EVENT_TYPE)
        {
            logData[3+argumentsAmount]="\nOutput: ";
            logData[4+argumentsAmount]=output;
        }

        //get logger
        Logger logger=this.getLogger();
        
        //log event
        switch(eventType)
        {
            case PRE_EVENT_TYPE:
            case POST_EVENT_TYPE:
                logger.logDebug(logData,throwable);
                break;
            case ERROR_EVENT_TYPE:
                logger.logError(logData,throwable);
                break;
        }
    }
1344498
private void filterLogEvent(final LogEvent logEvent) {
        for ( ILogEventFilter filter: this.filters) {
            // do nothing if one of the filters doesn't accept the event
            if ( !filter.acceptEvent( logEvent ) ) {
                return;
            }
        }
        // if all the filters accepted the event, signal the creation
        // of the event
        logEventCreated( logEvent );
    }
763619
function log_event(req, code, message, elapsed) {
  return {
    code:           code,
    message:        message,
    elapsed:        elapsed,
    request:        req,
    url:            req.originalUrl || req.url,
    method:         req.method,
    headers:        req.headers,
    httpVersion:    req.httpVersion,
    remoteAddress:  req.connection.remoteAddress
  };
}