org.resthub.web.log.DefaultLogStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resthub-web-server Show documentation
Show all versions of resthub-web-server Show documentation
RESThub support for REST webservices based on Spring MVC
package org.resthub.web.log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile;
import javax.inject.Named;
import java.text.SimpleDateFormat;
/**
* Default log strategy
*/
@Named("defaultLogStrategy")
@Profile("resthub-client-logging")
public class DefaultLogStrategy implements LogStrategy {
private static final Logger LOGGER = LoggerFactory.getLogger("JSLogger");
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
@Override
public void logError(Log log) {
LOGGER.error("[{}] {} {}", log.browser, DATE_FORMAT.format(log.time), log.message);
}
@Override
public void logWarn(Log log) {
LOGGER.warn("[{}] {} {}", log.browser, DATE_FORMAT.format(log.time), log.message);
}
@Override
public void logInfo(Log log) {
LOGGER.info("[{}] {} {}", log.browser, DATE_FORMAT.format(log.time), log.message);
}
@Override
public void logDebug(Log log) {
LOGGER.debug("[{}] {} {}", log.browser, DATE_FORMAT.format(log.time), log.message);
}
}