You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.4 KiB
121 lines
3.4 KiB
package com.fr.plugin.xxxx.bi.sync; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.log.FineLoggerProvider; |
|
import com.fr.plugin.context.PluginContexts; |
|
import com.fr.plugin.xxxx.bi.sync.config.SyncConfig; |
|
import com.fr.stable.StringUtils; |
|
|
|
/** |
|
* @author fr.open |
|
* @since 2021/12/04 |
|
*/ |
|
public final class LogUtils { |
|
private static final String DEBUG_PREFIX = "[插件调试] "; |
|
private static String LOG_PREFIX = Constants.PLUGIN_NAME; |
|
private static final String PLUGIN_VERSION; |
|
|
|
private static final FineLoggerProvider LOGGER = FineLoggerFactory.getLogger(); |
|
|
|
static { |
|
String version = PluginContexts.currentContext().getMarker().getVersion(); |
|
if (StringUtils.isNotBlank(version)) { |
|
PLUGIN_VERSION = "[v" + version + "] "; |
|
} else { |
|
PLUGIN_VERSION = "[unknown version] "; |
|
} |
|
|
|
LOG_PREFIX = LOG_PREFIX + PLUGIN_VERSION; |
|
} |
|
|
|
public static void setPrefix(String prefix) { |
|
if (prefix != null) { |
|
LOG_PREFIX = prefix; |
|
} |
|
} |
|
|
|
public static boolean isDebugEnabled() { |
|
return LOGGER.isDebugEnabled(); |
|
} |
|
|
|
public static void debug(String s) { |
|
LOGGER.debug(LOG_PREFIX + s); |
|
} |
|
|
|
public static void debug(String s, Object... objects) { |
|
LOGGER.debug(LOG_PREFIX + s, objects); |
|
} |
|
|
|
public static void debug(String s, Throwable throwable) { |
|
LOGGER.debug(LOG_PREFIX + s, throwable); |
|
} |
|
|
|
public static void debug4plugin(String s) { |
|
if (SyncConfig.getInstance().getDebugSwitch()) { |
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s); |
|
} else { |
|
LOGGER.debug(LOG_PREFIX + s); |
|
} |
|
} |
|
|
|
public static void debug4plugin(String s, Object... objects) { |
|
if (SyncConfig.getInstance().getDebugSwitch()) { |
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s, objects); |
|
} else { |
|
LOGGER.debug(LOG_PREFIX + s, objects); |
|
} |
|
} |
|
|
|
public static void debug4plugin(String s, Throwable throwable) { |
|
if (SyncConfig.getInstance().getDebugSwitch()) { |
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s, throwable); |
|
} else { |
|
LOGGER.debug(LOG_PREFIX + s, throwable); |
|
} |
|
} |
|
|
|
|
|
public static boolean isInfoEnabled() { |
|
return LOGGER.isInfoEnabled(); |
|
} |
|
|
|
public static void info(String s) { |
|
LOGGER.info(LOG_PREFIX + s); |
|
} |
|
|
|
public static void info(String s, Object... objects) { |
|
LOGGER.info(LOG_PREFIX + s, objects); |
|
} |
|
|
|
public static void warn(String s) { |
|
LOGGER.warn(LOG_PREFIX + s); |
|
} |
|
|
|
public static void warn(String s, Object... objects) { |
|
LOGGER.warn(LOG_PREFIX + s, objects); |
|
} |
|
|
|
public static void warn(String s, Throwable throwable) { |
|
LOGGER.warn(LOG_PREFIX + s, throwable); |
|
} |
|
|
|
public static void warn(Throwable throwable, String s, Object... objects) { |
|
LOGGER.warn(throwable, LOG_PREFIX + s, objects); |
|
} |
|
|
|
public static void error(String s) { |
|
LOGGER.error(LOG_PREFIX + s); |
|
} |
|
|
|
public static void error(String s, Object... objects) { |
|
LOGGER.error(LOG_PREFIX + s, objects); |
|
} |
|
|
|
public static void error(String s, Throwable throwable) { |
|
LOGGER.error(LOG_PREFIX + s, throwable); |
|
} |
|
|
|
public static void error(Throwable throwable, String s, Object... objects) { |
|
LOGGER.error(throwable, LOG_PREFIX + s, objects); |
|
} |
|
}
|
|
|