<commit_before>package com.sap.cloud.lm.sl.cf.process.util;

import java.sql.Timestamp;
import java.text.MessageFormat;

import org.activiti.engine.delegate.DelegateExecution;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

import com.sap.cloud.lm.sl.cf.core.util.UserMessageLogger;
import com.sap.cloud.lm.sl.cf.process.message.Messages;
import com.sap.cloud.lm.sl.cf.process.steps.StepsUtil;
import com.sap.cloud.lm.sl.common.SLException;
import com.sap.cloud.lm.sl.persistence.model.ProgressMessage;
import com.sap.cloud.lm.sl.persistence.model.ProgressMessage.ProgressMessageType;
import com.sap.cloud.lm.sl.persistence.services.ProcessLoggerProviderFactory;
import com.sap.cloud.lm.sl.persistence.services.ProgressMessageService;

/**
 * The purpose of this class is to group logging of progress messages and process logs in a single place.
 *
 */
public class StepLogger implements UserMessageLogger {

    public static final String PARENT_LOGGER = "com.sap.cloud.lm.sl.xs2";

    protected DelegateExecution context;
    protected ProgressMessageService progressMessageService;
    protected ProcessLoggerProviderFactory processLoggerProviderFactory;
    protected Logger simpleStepLogger;

    public StepLogger(DelegateExecution context, ProgressMessageService progressMessageService,
        ProcessLoggerProviderFactory processLoggerProviderFactory, Logger simpleStepLogger) {
        this.context = context;
        this.progressMessageService = progressMessageService;
        this.processLoggerProviderFactory = processLoggerProviderFactory;
        this.simpleStepLogger = simpleStepLogger;
    }

    public void logActivitiTask() {
        String message = MessageFormat.format(Messages.EXECUTING_TASK, context.getId(), context.getCurrentActivityId());
        debug(message);
    }

    public void infoWithoutProgressMessage(String pattern, Object... arguments) {
        infoWithoutProgressMessage(MessageFormat.format(pattern, arguments));
    }

    public void infoWithoutProgressMessage(String message) {
        simpleStepLogger.info(message);
        getProcessLogger().info(getPrefix(simpleStepLogger) + message);
    }

    public void info(String pattern, Object... arguments) {
        info(MessageFormat.format(pattern, arguments));
    }

    public void info(String message) {
        infoWithoutProgressMessage(message);
        sendProgressMessage(message, ProgressMessageType.INFO);
    }

    public void errorWithoutProgressMessage(Exception e, String pattern, Object... arguments) {
        errorWithoutProgressMessage(e, MessageFormat.format(pattern, arguments));
    }

    public void errorWithoutProgressMessage(Exception e, String message) {
        errorWithoutProgressMessage(getExtendedMessage(message, e));<commit_msg>Fix order of message arguments<commit_after>package com.sap.cloud.lm.sl.cf.process.util;

import java.sql.Timestamp;
import java.text.MessageFormat;

import org.activiti.engine.delegate.DelegateExecution;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

import com.sap.cloud.lm.sl.cf.core.util.UserMessageLogger;
import com.sap.cloud.lm.sl.cf.process.message.Messages;
import com.sap.cloud.lm.sl.cf.process.steps.StepsUtil;
import com.sap.cloud.lm.sl.common.SLException;
import com.sap.cloud.lm.sl.persistence.model.ProgressMessage;
import com.sap.cloud.lm.sl.persistence.model.ProgressMessage.ProgressMessageType;
import com.sap.cloud.lm.sl.persistence.services.ProcessLoggerProviderFactory;
import com.sap.cloud.lm.sl.persistence.services.ProgressMessageService;

/**
 * The purpose of this class is to group logging of progress messages and process logs in a single place.
 *
 */
public class StepLogger implements UserMessageLogger {

    public static final String PARENT_LOGGER = "com.sap.cloud.lm.sl.xs2";

    protected DelegateExecution context;
    protected ProgressMessageService progressMessageService;
    protected ProcessLoggerProviderFactory processLoggerProviderFactory;
    protected Logger simpleStepLogger;

    public StepLogger(DelegateExecution context, ProgressMessageService progressMessageService,
        ProcessLoggerProviderFactory processLoggerProviderFactory, Logger simpleStepLogger) {
        this.context = context;
        this.progressMessageService = progressMessageService;
        this.processLoggerProviderFactory = processLoggerProviderFactory;
        this.simpleStepLogger = simpleStepLogger;
    }

    public void logActivitiTask() {
        debug(Messages.EXECUTING_TASK, context.getCurrentActivityId(), context.getId());
    }

    public void infoWithoutProgressMessage(String pattern, Object... arguments) {
        infoWithoutProgressMessage(MessageFormat.format(pattern, arguments));
    }

    public void infoWithoutProgressMessage(String message) {
        simpleStepLogger.info(message);
        getProcessLogger().info(getPrefix(simpleStepLogger) + message);
    }

    public void info(String pattern, Object... arguments) {
        info(MessageFormat.format(pattern, arguments));
    }

    public void info(String message) {
        infoWithoutProgressMessage(message);
        sendProgressMessage(message, ProgressMessageType.INFO);
    }

    public void errorWithoutProgressMessage(Exception e, String pattern, Object... arguments) {
        errorWithoutProgressMessage(e, MessageFormat.format(pattern, arguments));
    }

    public void errorWithoutProgressMessage(Exception e, String message) {
        errorWithoutProgressMessage(getExtendedMessage(message, e));
{'fraction_non_alphanumeric': 0.08704271039826995, 'fraction_numerical': 0.0007208506037123806, 'mean_word_length': 4.617408906882591, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6445225', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1422, 'n_words': 290}