| | |
| | | package com.zy.common.utils; |
| | | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.common.service.WatchService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Array; |
| | |
| | | offer(NewsLevel.ERROR, format, arguments); |
| | | } |
| | | |
| | | public static void watchInfo(String key, String format, Object... arguments) { |
| | | info(format, arguments); |
| | | watchOffer(key, replace(format, arguments)); |
| | | } |
| | | |
| | | public static void watchWarn(String key, String format, Object... arguments) { |
| | | warn(format, arguments); |
| | | watchOffer(key, replace(format, arguments)); |
| | | } |
| | | |
| | | public static void watchError(String key, String format, Object... arguments) { |
| | | error(format, arguments); |
| | | watchOffer(key, replace(format, arguments)); |
| | | } |
| | | |
| | | public static void infoNoLog(String format, Object... arguments) { |
| | | offer(NewsLevel.INFO, format, arguments); |
| | | } |
| | |
| | | return NEWS_QUEUE.offer(new NewsDomain(level, replace(msg, args), (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()))); |
| | | } |
| | | |
| | | private static boolean watchOffer(String key, String msg) { |
| | | WatchService watchService = SpringUtils.getBean(WatchService.class); |
| | | if(watchService != null) { |
| | | return watchService.push(key, msg); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private static String replace(String str, Object[] objs){ |
| | | if (null == objs || objs.length == 0 || null == str || "".equals(str.trim())) { |
| | | return str; |