mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 23:00:24 -08:00
Add configuration options to enable database logging
This commit is contained in:
@@ -346,7 +346,7 @@ void Server::externalRoomSay(int roomId, const QString &userName, const QString
|
|||||||
}
|
}
|
||||||
room->say(userName, message, false);
|
room->say(userName, message, false);
|
||||||
|
|
||||||
getDatabaseInterface()->logMessage(0, userName, "ISL", message, Server_DatabaseInterface::MessageTargetRoom, room->getId(), room->getName());
|
getDatabaseInterface()->logMessage(0, userName, "ISL", message, Server_DatabaseInterface::MessageTargetIslRoom, room->getId(), room->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::externalRoomGameListChanged(int roomId, const ServerInfo_Game &gameInfo)
|
void Server::externalRoomGameListChanged(int roomId, const ServerInfo_Game &gameInfo)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
virtual bool getRequireRegistration() { return false; }
|
virtual bool getRequireRegistration() { return false; }
|
||||||
|
|
||||||
enum LogMessage_TargetType { MessageTargetRoom, MessageTargetGame, MessageTargetChat };
|
enum LogMessage_TargetType { MessageTargetRoom, MessageTargetGame, MessageTargetChat, MessageTargetIslRoom };
|
||||||
virtual void logMessage(const int senderId, const QString &senderName, const QString &senderIp, const QString &logMessage, LogMessage_TargetType targetType, const int targetId, const QString &targetName) { };
|
virtual void logMessage(const int senderId, const QString &senderName, const QString &senderIp, const QString &logMessage, LogMessage_TargetType targetType, const int targetId, const QString &targetName) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ password=foobar
|
|||||||
|
|
||||||
[rooms]
|
[rooms]
|
||||||
|
|
||||||
; A servtrice server can expose to the users different "rooms" to chat and create games. Rooms can be defined
|
; A servatrice server can expose to the users different "rooms" to chat and create games. Rooms can be defined
|
||||||
; with two different methods:
|
; with two different methods:
|
||||||
; config: rooms are defined in this configuration (see the following example)
|
; config: rooms are defined in this configuration (see the following example)
|
||||||
; sql: rooms are defined in the "rooms" table of the database
|
; sql: rooms are defined in the "rooms" table of the database
|
||||||
@@ -144,6 +144,24 @@ max_message_count_per_interval=10
|
|||||||
max_games_per_user=5
|
max_games_per_user=5
|
||||||
|
|
||||||
|
|
||||||
|
[logging]
|
||||||
|
|
||||||
|
; Servatrice can log user messages to the database table cockatrice_log.
|
||||||
|
; These messages can come from different sources; each source can be enabled separately.
|
||||||
|
|
||||||
|
; Log user messages inside chat rooms
|
||||||
|
log_user_msg_room=false
|
||||||
|
|
||||||
|
; Log user messages inside games
|
||||||
|
log_user_msg_game=false
|
||||||
|
|
||||||
|
; Log user messages in private chats
|
||||||
|
log_user_msg_chat=false
|
||||||
|
|
||||||
|
; Log user messages coming from other servers in the network
|
||||||
|
log_user_msg_isl=false
|
||||||
|
|
||||||
|
|
||||||
; EXPERIMENTAL - NOT WORKING YET
|
; EXPERIMENTAL - NOT WORKING YET
|
||||||
; The following settings are relative to the server network functionality, that is not yet complete.
|
; The following settings are relative to the server network functionality, that is not yet complete.
|
||||||
; Avoid enabling it unless you are willing to test it and help its development.
|
; Avoid enabling it unless you are willing to test it and help its development.
|
||||||
|
|||||||
@@ -546,15 +546,29 @@ void Servatrice_DatabaseInterface::logMessage(const int senderId, const QString
|
|||||||
switch(targetType)
|
switch(targetType)
|
||||||
{
|
{
|
||||||
case MessageTargetRoom:
|
case MessageTargetRoom:
|
||||||
|
if(!settingsCache->value("logging/log_user_msg_room", 0).toBool())
|
||||||
|
return;
|
||||||
targetTypeString = "room";
|
targetTypeString = "room";
|
||||||
break;
|
break;
|
||||||
case MessageTargetGame:
|
case MessageTargetGame:
|
||||||
|
if(!settingsCache->value("logging/log_user_msg_game", 0).toBool())
|
||||||
|
return;
|
||||||
targetTypeString = "game";
|
targetTypeString = "game";
|
||||||
break;
|
break;
|
||||||
case MessageTargetChat:
|
case MessageTargetChat:
|
||||||
|
if(!settingsCache->value("logging/log_user_msg_chat", 0).toBool())
|
||||||
|
return;
|
||||||
targetTypeString = "chat";
|
targetTypeString = "chat";
|
||||||
break;
|
break;
|
||||||
|
case MessageTargetIslRoom:
|
||||||
|
if(!settingsCache->value("logging/log_user_msg_isl", 0).toBool())
|
||||||
|
return;
|
||||||
|
targetTypeString = "room";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
query.prepare("insert into " + server->getDbPrefix() + "_log (log_time, sender_id, sender_name, sender_ip, log_message, target_type, target_id, target_name) values (now(), :sender_id, :sender_name, :sender_ip, :log_message, :target_type, :target_id, :target_name)");
|
query.prepare("insert into " + server->getDbPrefix() + "_log (log_time, sender_id, sender_name, sender_ip, log_message, target_type, target_id, target_name) values (now(), :sender_id, :sender_name, :sender_ip, :log_message, :target_type, :target_id, :target_name)");
|
||||||
query.bindValue(":sender_id", senderId);
|
query.bindValue(":sender_id", senderId);
|
||||||
query.bindValue(":sender_name", senderName);
|
query.bindValue(":sender_name", senderName);
|
||||||
|
|||||||
Reference in New Issue
Block a user