package net.northking.cctp.element.log;

import net.northking.cctp.element.util.Assert;
import org.slf4j.LoggerFactory;

/**
 * Default logger
 *
 * @author fengxiang.zhang
 * @since 1.0
 */
public class Slf4jLogger implements Logger {

    private static org.slf4j.Logger logger = LoggerFactory.getLogger(Slf4jLogger.class);

    @Override
    public void info(String message) {
        logger.info(message);
    }

    @Override
    public void info(String format, Object... arguments) {
        logger.info(format, arguments);
    }

    @Override
    public void error(String message) {
        logger.error(message);
    }

    @Override
    public void error(String format, Object... arguments) {
        logger.error(format, arguments);
    }

    @Override
    public void debug(String message) {
        logger.debug(message);
    }

    @Override
    public void debug(String format, Object... arguments) {
        logger.debug(format, arguments);
    }

    @Override
    public void warn(String message) {
        logger.warn(message);
    }

    @Override
    public void warn(String format, Object... arguments) {
        logger.warn(format, arguments);
    }

    @Override
    public void log(Level level, String format, Object... arguments) {
        Assert.notNull(level, "日志级别不能为空");
        switch (level) {
            case ERROR:
                logger.error(format, arguments);
                break;
            case WARN:
                logger.warn(format, arguments);
                break;
            case INFO:
                logger.info(format, arguments);
                break;
            case DEBUG:
                logger.debug(format, arguments);
                break;
            default:
                logger.info(format, arguments);
                break;
        }
    }

}