package com.jeeplus.sys.factory;

import com.jeeplus.sys.domain.Log;
import com.jeeplus.sys.feign.ILogApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author jeeplus
 */
@Slf4j
@Component
public class LogApiFallbackFactory implements FallbackFactory <ILogApi> {

    @Override
    public ILogApi create(Throwable throwable) {
        log.error ( "日志服务调用失败:{}", throwable.getMessage ( ) );
        throwable.printStackTrace ( );
        return new ILogApi ( ) {
            @Override
            public void save(Log log) {

            }
        };
    }
}
