直播状态改为人气值判断
日志系统支持过滤 其他
This commit is contained in:
parent
5a49fc831a
commit
efcb7e5ac2
@ -294,7 +294,7 @@ public class Live implements ApplicationContextAware {
|
|||||||
processData(list.get(i), data);
|
processData(list.get(i), data);
|
||||||
tmp +="|||"+i+"[start] "+ list.get(i)+ " [end]||| ";
|
tmp +="|||"+i+"[start] "+ list.get(i)+ " [end]||| ";
|
||||||
}
|
}
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, "list size = " + list.size() + " data = " + tmp);
|
// Log.i(AppTools.getToDayTimeToString(startTime), roomId, "list size = " + list.size() + " data = " + tmp);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
JSONObject json = JSONObject.parseObject(new String(bytes, StandardCharsets.UTF_8));
|
JSONObject json = JSONObject.parseObject(new String(bytes, StandardCharsets.UTF_8));
|
||||||
@ -302,8 +302,14 @@ public class Live implements ApplicationContextAware {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
int popular = LiveUtils.bytesToInt2(bytes, 0);
|
int popular = LiveUtils.bytesToInt2(bytes, 0);
|
||||||
info.setPopular(popular);
|
info.setPopular(popular);
|
||||||
|
if(popular>1){
|
||||||
|
upData.setLive(1);
|
||||||
|
}else{
|
||||||
|
upData.setLive(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
com.yutou.bilibili.Tools.Log.i("----------ERROR----------");
|
com.yutou.bilibili.Tools.Log.i("----------ERROR----------");
|
||||||
@ -340,11 +346,10 @@ public class Live implements ApplicationContextAware {
|
|||||||
BilibiliLiveData liveData = new BilibiliLiveData();
|
BilibiliLiveData liveData = new BilibiliLiveData();
|
||||||
String danmu;
|
String danmu;
|
||||||
GiftData giftData;
|
GiftData giftData;
|
||||||
|
Log.i(AppTools.getToDayTimeToString(startTime),roomId,json.toJSONString());
|
||||||
switch (json.getString("cmd")) {
|
switch (json.getString("cmd")) {
|
||||||
case "INTERACT_WORD"://普通用户进直播间
|
case "INTERACT_WORD"://普通用户进直播间
|
||||||
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";
|
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
||||||
liveData.setType(LiveData.INTERACT_WORD);
|
liveData.setType(LiveData.INTERACT_WORD);
|
||||||
liveData.setMsg(danmu);
|
liveData.setMsg(danmu);
|
||||||
@ -370,7 +375,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
danmuManager.addDanmu(danmuData);
|
danmuManager.addDanmu(danmuData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
break;
|
break;
|
||||||
case "SEND_GIFT"://送礼
|
case "SEND_GIFT"://送礼
|
||||||
data = json.getJSONObject("data");
|
data = json.getJSONObject("data");
|
||||||
@ -397,7 +401,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setRoomid(roomId);
|
liveData.setRoomid(roomId);
|
||||||
info.setGiftuser(info.getGiftuser() + 1);
|
info.setGiftuser(info.getGiftuser() + 1);
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
break;
|
break;
|
||||||
case "COMBO_SEND"://礼物连击
|
case "COMBO_SEND"://礼物连击
|
||||||
data = json.getJSONObject("data");
|
data = json.getJSONObject("data");
|
||||||
@ -428,7 +431,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setRoomid(roomId);
|
liveData.setRoomid(roomId);
|
||||||
info.setGiftuser(info.getGiftuser() + 1);
|
info.setGiftuser(info.getGiftuser() + 1);
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
break;
|
break;
|
||||||
case "ENTRY_EFFECT"://舰长进直播间
|
case "ENTRY_EFFECT"://舰长进直播间
|
||||||
info.setVipuserindex(info.getVipuserindex() + 1);
|
info.setVipuserindex(info.getVipuserindex() + 1);
|
||||||
@ -439,7 +441,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setRoomid(roomId);
|
liveData.setRoomid(roomId);
|
||||||
liveData.setSubtime(new Date());
|
liveData.setSubtime(new Date());
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
break;
|
break;
|
||||||
case "LIVE_INTERACTIVE_GAME"://彩色弹幕?通过游戏弹幕
|
case "LIVE_INTERACTIVE_GAME"://彩色弹幕?通过游戏弹幕
|
||||||
break;
|
break;
|
||||||
@ -459,7 +460,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setSubtime(new Date());
|
liveData.setSubtime(new Date());
|
||||||
info.setGiftuser(info.getGiftuser() + 1);
|
info.setGiftuser(info.getGiftuser() + 1);
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, danmu);
|
|
||||||
break;
|
break;
|
||||||
case "USER_TOAST_MSG":
|
case "USER_TOAST_MSG":
|
||||||
break;
|
break;
|
||||||
@ -477,7 +477,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setRoomid(roomId);
|
liveData.setRoomid(roomId);
|
||||||
info.setGiftuser(info.getGiftuser() + 1);
|
info.setGiftuser(info.getGiftuser() + 1);
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, liveData.toString());
|
|
||||||
break;
|
break;
|
||||||
case "LIVE"://开始直播,不过有在心跳包上做检测了,所以也无所谓?
|
case "LIVE"://开始直播,不过有在心跳包上做检测了,所以也无所谓?
|
||||||
if (upData.getLive() == 1) {
|
if (upData.getLive() == 1) {
|
||||||
@ -505,7 +504,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
QQBotManager.getInstance().sendMessage(file, builder.toString());
|
QQBotManager.getInstance().sendMessage(file, builder.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, upData.getName() + "开播了!");
|
|
||||||
break;
|
break;
|
||||||
case "PREPARING"://
|
case "PREPARING"://
|
||||||
case "SUPER_CHAT_MESSAGE_JPN":
|
case "SUPER_CHAT_MESSAGE_JPN":
|
||||||
@ -536,7 +534,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
liveData.setRoomid(roomId);
|
liveData.setRoomid(roomId);
|
||||||
liveData.setSubtime(new Date());
|
liveData.setSubtime(new Date());
|
||||||
service.addLiveData(liveData);
|
service.addLiveData(liveData);
|
||||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, liveData.toString());
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
@ -619,7 +616,6 @@ public class Live implements ApplicationContextAware {
|
|||||||
outputStream.write("[object Object]".getBytes(StandardCharsets.UTF_8));
|
outputStream.write("[object Object]".getBytes(StandardCharsets.UTF_8));
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
client.send(outputStream.toByteArray());
|
client.send(outputStream.toByteArray());
|
||||||
checkLive();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
com.yutou.bilibili.Tools.Log.i(client.isClosed());
|
com.yutou.bilibili.Tools.Log.i(client.isClosed());
|
||||||
|
@ -25,6 +25,7 @@ import java.util.zip.Inflater;
|
|||||||
|
|
||||||
public class LiveUtils {
|
public class LiveUtils {
|
||||||
private static String cookie = null;
|
private static String cookie = null;
|
||||||
|
private static Map<Integer,Boolean> liveStateMap=new HashMap<>();
|
||||||
|
|
||||||
public LiveUtils() {
|
public LiveUtils() {
|
||||||
|
|
||||||
@ -353,6 +354,12 @@ public class LiveUtils {
|
|||||||
private static JSONObject getLiveState(int roomId){
|
private static JSONObject getLiveState(int roomId){
|
||||||
return http_get("https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=" + roomId);
|
return http_get("https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=" + roomId);
|
||||||
}
|
}
|
||||||
|
public static void reloadLiveState(int roomId){
|
||||||
|
JSONObject json = getLiveState(roomId);
|
||||||
|
if(json!=null){
|
||||||
|
liveStateMap.put(roomId,json.getJSONObject("data").getInteger("live_status") == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getLiveTitle(int roomId) {
|
public static String getLiveTitle(int roomId) {
|
||||||
JSONObject json =getLiveInfo(roomId);
|
JSONObject json =getLiveInfo(roomId);
|
||||||
@ -363,11 +370,12 @@ public class LiveUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLivePlayer(int roomId) {
|
public static boolean isLivePlayer(int roomId) {
|
||||||
JSONObject json = getLiveState(roomId);
|
/* if (liveStateMap.containsKey(roomId)) {
|
||||||
if (json == null) {
|
return liveStateMap.get(roomId);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return json.getJSONObject("data").getInteger("live_status") == 1;
|
reloadLiveState(roomId);
|
||||||
|
return false;*/
|
||||||
|
return Live.lives.get(roomId).geData().getLive()==1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkLiveSave(int roomId) {
|
private static void checkLiveSave(int roomId) {
|
||||||
|
@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class BilibiliApplication {
|
public class BilibiliApplication {
|
||||||
|
|
||||||
public static String version="0.7.4.1";
|
public static String version="0.7.4.4";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
QQBotManager.getInstance().init();
|
QQBotManager.getInstance().init();
|
||||||
|
@ -9,6 +9,7 @@ import com.yutou.bilibili.BiliBili.Tools.BiliTools;
|
|||||||
import com.yutou.bilibili.Services.IUserService;
|
import com.yutou.bilibili.Services.IUserService;
|
||||||
import com.yutou.bilibili.Tools.AppTools;
|
import com.yutou.bilibili.Tools.AppTools;
|
||||||
import com.yutou.bilibili.Tools.Config;
|
import com.yutou.bilibili.Tools.Config;
|
||||||
|
import com.yutou.bilibili.Tools.RedisTools;
|
||||||
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
||||||
import com.yutou.bilibili.mybatis.model.UBiliUp;
|
import com.yutou.bilibili.mybatis.model.UBiliUp;
|
||||||
import com.yutou.bilibili.mybatis.model.UUser;
|
import com.yutou.bilibili.mybatis.model.UUser;
|
||||||
@ -50,6 +51,7 @@ public class UserController {
|
|||||||
user.setPower("[1,2,3,5,6,7]");
|
user.setPower("[1,2,3,5,6,7]");
|
||||||
user.setSubtime(new Date());
|
user.setSubtime(new Date());
|
||||||
user.setLogintoken(UUID.randomUUID().toString());
|
user.setLogintoken(UUID.randomUUID().toString());
|
||||||
|
RedisTools.set(user.getLogintoken(),user.getId()+"",30*24*60);
|
||||||
AppTools.setCookie(response, "login", user.getLogintoken(), -1);
|
AppTools.setCookie(response, "login", user.getLogintoken(), -1);
|
||||||
boolean flag = service.reg(user);
|
boolean flag = service.reg(user);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@ -69,8 +71,8 @@ public class UserController {
|
|||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
if (service.login(user.getUser(), user.getPassword())) {
|
if (service.login(user.getUser(), user.getPassword())) {
|
||||||
user = service.getUser(user.getUser());
|
user = service.getUser(user.getUser());
|
||||||
user.setLogintoken(UUID.randomUUID().toString());
|
//user.setLogintoken(UUID.randomUUID().toString());
|
||||||
service.update(user);
|
RedisTools.set(user.getLogintoken(),user.getId()+"",30*24*60);
|
||||||
AppTools.setCookie(response, "login", user.getLogintoken(), -1);
|
AppTools.setCookie(response, "login", user.getLogintoken(), -1);
|
||||||
json.put("msg", "登陆成功");
|
json.put("msg", "登陆成功");
|
||||||
json.put("power", user.getPower());
|
json.put("power", user.getPower());
|
||||||
@ -92,6 +94,7 @@ public class UserController {
|
|||||||
} else {
|
} else {
|
||||||
UUser user = service.getUserToToken(token);
|
UUser user = service.getUserToToken(token);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
RedisTools.remove(user.getLogintoken());
|
||||||
user.setLogintoken("");
|
user.setLogintoken("");
|
||||||
service.update(user);
|
service.update(user);
|
||||||
AppTools.deleteCookie(request, response, "login");
|
AppTools.deleteCookie(request, response, "login");
|
||||||
@ -114,7 +117,7 @@ public class UserController {
|
|||||||
json.put("code", -1);
|
json.put("code", -1);
|
||||||
json.put("msg", "未登录");
|
json.put("msg", "未登录");
|
||||||
} else {
|
} else {
|
||||||
UUser loginUser = service.getUserToToken(token);
|
UUser loginUser = service.getUserToUid(Integer.parseInt(RedisTools.get(token)));
|
||||||
if (loginUser != null) {
|
if (loginUser != null) {
|
||||||
user.setLogintoken("");
|
user.setLogintoken("");
|
||||||
user.setId(loginUser.getId());
|
user.setId(loginUser.getId());
|
||||||
@ -144,8 +147,7 @@ public class UserController {
|
|||||||
} else {
|
} else {
|
||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
json.put("msg", "ok");
|
json.put("msg", "ok");
|
||||||
UUser user = service.getUserToToken(token);
|
json.put("data", service.getUserUp(Integer.parseInt(RedisTools.get(token))));
|
||||||
json.put("data", service.getUserUp(user.getId()));
|
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
@ -159,7 +161,6 @@ public class UserController {
|
|||||||
json.put("code", "-1");
|
json.put("code", "-1");
|
||||||
json.put("msg", "未登录");
|
json.put("msg", "未登录");
|
||||||
} else {
|
} else {
|
||||||
UUser user = service.getUserToToken(token);
|
|
||||||
int roomid = 0;
|
int roomid = 0;
|
||||||
if (!info.getUrl().startsWith("http")) {
|
if (!info.getUrl().startsWith("http")) {
|
||||||
info.setUrl("https://live.bilibili.com/" + info.getUrl());
|
info.setUrl("https://live.bilibili.com/" + info.getUrl());
|
||||||
@ -181,7 +182,7 @@ public class UserController {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
UBiliUp up = new UBiliUp();
|
UBiliUp up = new UBiliUp();
|
||||||
up.setUid(user.getId());
|
up.setUid(Integer.parseInt(RedisTools.get(token)));
|
||||||
up.setRoomid(roomid);
|
up.setRoomid(roomid);
|
||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
json.put("msg", service.addUp(up) ? "添加成功" : "添加失败");
|
json.put("msg", service.addUp(up) ? "添加成功" : "添加失败");
|
||||||
@ -198,7 +199,7 @@ public class UserController {
|
|||||||
json.put("code", -1);
|
json.put("code", -1);
|
||||||
json.put("msg", "未登录");
|
json.put("msg", "未登录");
|
||||||
} else {
|
} else {
|
||||||
UUser user = service.getUserToToken(token);
|
UUser user = service.getUserToUid(Integer.parseInt(RedisTools.get(token)));;
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
json.put("code", -2);
|
json.put("code", -2);
|
||||||
json.put("msg", "未登录");
|
json.put("msg", "未登录");
|
||||||
|
@ -235,8 +235,8 @@ public class QQBotManager implements ApplicationContextAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void myGroup(String msg) {
|
private void myGroup(String message) {
|
||||||
msg = msg.replace("!", "!").toLowerCase();
|
String msg = message.replace("!", "!").toLowerCase();
|
||||||
msg=msg.trim();
|
msg=msg.trim();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
JSONObject json;
|
JSONObject json;
|
||||||
@ -346,19 +346,9 @@ public class QQBotManager implements ApplicationContextAware {
|
|||||||
}
|
}
|
||||||
} else if (msg.startsWith(QQCommands.QQ_SYSTEM_LOG)) {
|
} else if (msg.startsWith(QQCommands.QQ_SYSTEM_LOG)) {
|
||||||
try {
|
try {
|
||||||
cmd = msg.split(" ");
|
cmd = message.replace("!","!").replace(QQCommands.QQ_SYSTEM_LOG,"").split(" ");
|
||||||
switch (cmd[1]){
|
RedisTools.set(1,"live-log",cmd[1].trim());
|
||||||
case "true":
|
getInstance().sendMessage("日志设为:"+cmd[1].trim());
|
||||||
RedisTools.set(1,"live-log","true");
|
|
||||||
getInstance().sendMessage("日志设为 true");
|
|
||||||
break;
|
|
||||||
case "false":
|
|
||||||
RedisTools.set(1,"live-log","false");
|
|
||||||
getInstance().sendMessage("日志设为 false");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
getInstance().sendMessage("设置错误,"+QQCommands.QQ_SYSTEM_LOG +" true|false");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ public interface IUserService {
|
|||||||
boolean removeUp(UUser user,UBiliUp up);
|
boolean removeUp(UUser user,UBiliUp up);
|
||||||
boolean update(UUser user);
|
boolean update(UUser user);
|
||||||
UUser getUser(String uname);
|
UUser getUser(String uname);
|
||||||
|
UUser getUserToUid(Integer uid);
|
||||||
UUser getUserToToken(String token);
|
UUser getUserToToken(String token);
|
||||||
List<UBiliUp> getUserUp(int uid);
|
List<UBiliUp> getUserUp(int uid);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ public class UserServiceImpl implements IUserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUser getUserToUid(Integer uid) {
|
||||||
|
return userDao.selectByPrimaryKey(uid);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UBiliUp> getUserUp(int uid) {
|
public List<UBiliUp> getUserUp(int uid) {
|
||||||
UBiliUpExample example=new UBiliUpExample();
|
UBiliUpExample example=new UBiliUpExample();
|
||||||
|
@ -47,7 +47,7 @@ public class APIFilter implements Filter {
|
|||||||
){
|
){
|
||||||
filterChain.doFilter(servletRequest,servletResponse);
|
filterChain.doFilter(servletRequest,servletResponse);
|
||||||
}else {
|
}else {
|
||||||
UUser user= service.getUserToToken(token);
|
UUser user= service.getUserToUid(Integer.parseInt(RedisTools.get(token)));;
|
||||||
if(user==null){
|
if(user==null){
|
||||||
response.sendRedirect("/");
|
response.sendRedirect("/");
|
||||||
}else{
|
}else{
|
||||||
|
@ -94,6 +94,7 @@ public class ApplicationInit implements ApplicationRunner {
|
|||||||
|
|
||||||
private void checkLive() {
|
private void checkLive() {
|
||||||
for (BilibiliUpInfo info : service.getUpInfo()) {
|
for (BilibiliUpInfo info : service.getUpInfo()) {
|
||||||
|
// LiveUtils.reloadLiveState(info.getRoomid());
|
||||||
if (info.getOfflinelistening() == 1) {
|
if (info.getOfflinelistening() == 1) {
|
||||||
if (info.getEnable() == 1) {
|
if (info.getEnable() == 1) {
|
||||||
Live live = LiveUtils.liveContains(info);
|
Live live = LiveUtils.liveContains(info);
|
||||||
@ -111,7 +112,7 @@ public class ApplicationInit implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0, 60 * 1000);
|
}, 0, 2*60 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
|
|
||||||
public static void i(Object log) {
|
public static void i(Object log) {
|
||||||
if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) {
|
if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) {
|
||||||
return;
|
return;
|
||||||
@ -25,23 +26,30 @@ public class Log {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i(e.getMessage());
|
i(e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
public static void i(String timer,int roomId,Object log){
|
|
||||||
String logFlag=RedisTools.get("live-log",1);
|
public static void i(String timer, int roomId, Object log) {
|
||||||
if("true".equals(logFlag)) {
|
String logFlag = RedisTools.get("live-log", 1);
|
||||||
getLogger("[" + timer.replace(":", "_") + "]" + roomId).log(Level.INFO, log.toString());
|
if (logFlag.startsWith("true")) {
|
||||||
|
if (logFlag.contains("|")) {
|
||||||
|
if (log.toString().contains(logFlag.split("\\|")[1])) {
|
||||||
|
getLogger("[" + timer.replace(":", "_") + "]" + roomId).log(Level.INFO, log.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getLogger("[" + timer.replace(":", "_") + "]" + roomId).log(Level.INFO, log.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Logger getLogger(String fileName){
|
public static Logger getLogger(String fileName) {
|
||||||
if(logger==null){
|
if (logger == null) {
|
||||||
try {
|
try {
|
||||||
if(!new File("logs").exists()){
|
if (!new File("logs").exists()) {
|
||||||
new File("logs").mkdirs();
|
new File("logs").mkdirs();
|
||||||
}
|
}
|
||||||
logger=Logger.getLogger("Live-Log");
|
logger = Logger.getLogger("Live-Log");
|
||||||
FileHandler handler=new FileHandler("logs"+ File.separator+fileName+".log");
|
FileHandler handler = new FileHandler("logs" + File.separator + fileName + ".log");
|
||||||
logger.addHandler(handler);
|
logger.addHandler(handler);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user