aquality.selenium.core.localization.LocalizedLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aquality-selenium-core Show documentation
Show all versions of aquality-selenium-core Show documentation
Library with core functions simplifying work with Selenium-controlled applications.
package aquality.selenium.core.localization;
import aquality.selenium.core.configurations.ILoggerConfiguration;
import aquality.selenium.core.logging.Logger;
import com.google.inject.Inject;
/**
* LocalizedLogger class.
*
* @author lenovo
* @version $Id: $Id
*/
public class LocalizedLogger implements ILocalizedLogger {
private final ILocalizationManager localizationManager;
private final Logger logger;
private final ILoggerConfiguration loggerConfiguration;
@Inject
/**
* Constructor for LocalizedLogger.
*
* @param localizationManager a {@link aquality.selenium.core.localization.ILocalizationManager} object.
* @param logger a {@link aquality.selenium.core.logging.Logger} object.
* @param loggerConfiguration a {@link aquality.selenium.core.configurations.ILoggerConfiguration} object.
*/
public LocalizedLogger(ILocalizationManager localizationManager, Logger logger, ILoggerConfiguration loggerConfiguration) {
this.localizationManager = localizationManager;
this.logger = logger;
this.loggerConfiguration = loggerConfiguration;
}
private String localizeMessage(String messageKey, Object... args) {
return localizationManager.getLocalizedMessage(messageKey, args);
}
/** {@inheritDoc} */
@Override
public ILoggerConfiguration getConfiguration() {
return loggerConfiguration;
}
/** {@inheritDoc} */
@Override
public void infoElementAction(String elementType, String elementName, String messageKey, Object... args) {
String message = String.format("%1$s '%2$s' :: %3$s", elementType, elementName, localizeMessage(messageKey, args));
logger.info(message);
}
/** {@inheritDoc} */
@Override
public void info(String messageKey, Object... args) {
logger.info(localizeMessage(messageKey, args));
}
/** {@inheritDoc} */
@Override
public void debug(String messageKey, Object... args) {
logger.debug(localizeMessage(messageKey, args));
}
/** {@inheritDoc} */
@Override
public void debug(String messageKey, Throwable throwable, Object... args) {
logger.debug(localizeMessage(messageKey, args), throwable);
}
/** {@inheritDoc} */
@Override
public void warn(String messageKey, Object... args) {
logger.warn(localizeMessage(messageKey, args));
}
/** {@inheritDoc} */
@Override
public void error(String messageKey, Object... args) {
logger.error(localizeMessage(messageKey, args));
}
/** {@inheritDoc} */
@Override
public void fatal(String messageKey, Throwable throwable, Object... args) {
logger.fatal(localizeMessage(messageKey, args), throwable);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy