package com.ruoyi.common.dev.mybatis;

public class SQLQueue
{
    private static final ThreadLocal<SQLQuery> _state = new ThreadLocal<>();

    private static SQLQuery SQLQUERY()
    {
        SQLQuery sqlQuery = _state.get();
        if(null == sqlQuery)
        {
            sqlQuery = new SQLQuery();
            _state.set(sqlQuery);
        }
        return sqlQuery;
    }

    public static void Error(String mapper, String log)
    {
        if(log == null || log.isEmpty())
            return;
        SQLQUERY().Error(mapper, log);
    }

    public static void Debug(String mapper, String log)
    {
        if(log == null || log.isEmpty())
            return;
        SQLQUERY().Debug(mapper, log);
    }

    public static void Trace(String mapper, String log)
    {
        if(log == null || log.isEmpty())
            return;
        SQLQUERY().Trace(mapper, log);
    }

    public static void Warning(String mapper, String log)
    {
        if(log == null || log.isEmpty())
            return;
        SQLQUERY().Warning(mapper, log);
    }

    public static void Exception(String mapper, String log, Throwable e)
    {
        if(log == null || log.isEmpty())
            return;
        if(null != e)
            SQLQUERY().Exception(mapper, log, e);
        else
            SQLQUERY().Error(mapper, log);
    }
}
