summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt4
-rw-r--r--conf/Changelog.txt1
-rw-r--r--conf/log_athena.conf60
-rw-r--r--src/map/log.c126
-rw-r--r--src/map/log.h3
5 files changed, 90 insertions, 104 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 7c788323d..f6c984a6c 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -2,6 +2,10 @@ Date (YYYY-MM-DD)
Added
2011-12-24
+ * Merged log settings for SQL tables and TXT flat files (meaning depends on sql_logs setting). [Ai4rei]
+ - Added a warning when attempting to use SQL logs on TXT.
+ - Information about enabled logs is now displayed after all log config is read instead of per-hit.
+ - Removed unused member 'drop' from Log_Config (follow up to r6510).
* Added constants for log item filter constants. [Ai4rei]
- Removed argument in should_log_item, which always took log_config.filter as value.
- Fixed missed update in struct Log_Config, enum log_what -> e_log_pick_type (since r15040).
diff --git a/conf/Changelog.txt b/conf/Changelog.txt
index 715133a6f..9e5bafd00 100644
--- a/conf/Changelog.txt
+++ b/conf/Changelog.txt
@@ -1,6 +1,7 @@
Date Added
2011/12/24
+ * Rev. 15042 Merged log settings for SQL tables and TXT flat files (log_*_db, meaning depends on sql_logs setting). [Ai4rei]
* Rev. 15040 Updates to log_athena.conf [Ai4rei]
- Setting 'enable_logs' is now a pure bitmask and no longer affects misc-logs (branch, zeny etc). Meaning of most bits changed, revise your log configuration before starting the server.
- Where applicable, settings support hexadecimal and boolean values instead of only integers.
diff --git a/conf/log_athena.conf b/conf/log_athena.conf
index 2578c67cf..9e4492ada 100644
--- a/conf/log_athena.conf
+++ b/conf/log_athena.conf
@@ -105,48 +105,36 @@ log_chat: 0
// Disable chat logging when WoE is running? (Note 1)
log_chat_woe_disable: no
-// Dead Branch Log Table
-log_branch_db: branchlog
+// Logging tables/files
+// Following settings specify where to log to. If 'sql_logs' is
+// enabled, SQL tables are assumed, otherwise flat files.
-// Drops & Pickups Table
-log_pick_db: picklog
+// Dead Branch Log
+log_branch_db: log/branchlog.log
+//log_branch_db: branchlog
-// Zeny Table
-log_zeny_db: zenylog
+// Drops & Pickups
+log_pick_db: log/picklog.log
+//log_pick_db: picklog
-// MVP Drop Table
-log_mvpdrop_db: mvplog
+// Zeny
+log_zeny_db: log/zenylog.log
+//log_zeny_db: zenylog
-// GM Log Table
-log_gm_db: atcommandlog
+// MVP Drops
+log_mvpdrop_db: log/mvplog.log
+//log_mvpdrop_db: mvplog
-// NPC Log Table
-log_npc_db: npclog
+// GM Log
+log_gm_db: log/atcommandlog.log
+//log_gm_db: atcommandlog
-// CHAT Log Table
-log_chat_db: chatlog
-
-
-// Dead Branch Log File
-log_branch_file: log/branchlog.log
-
-// Drops & Pickups Log File
-log_pick_file: log/picklog.log
-
-// Zeny Log File
-log_zeny_file: log/zenylog.log
-
-// MVP Drop File
-log_mvpdrop_file: log/mvplog.log
-
-// GM Log File
-log_gm_file: log/atcommandlog.log
-
-// NPC Log File
-log_npc_file: log/npclog.log
-
-// CHAT Log File
-log_chat_file: log/chatlog.log
+// NPC Log
+log_npc_db: log/npclog.log
+//log_npc_db: npclog
+// CHAT Log
+log_chat_db: log/chatlog.log
+//log_chat_db: chatlog
import: conf/import/log_conf.txt
diff --git a/src/map/log.c b/src/map/log.c
index 62b80a6c0..8f9ed2a91 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -132,7 +132,7 @@ void log_branch(struct map_session_data *sd)
{
SqlStmt* stmt;
stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch_db, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
{
@@ -176,14 +176,14 @@ void log_pick_pc(struct map_session_data *sd, e_log_pick_type type, int nameid,
{
if( itm == NULL ) { //We log common item
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%s')",
- log_config.log_pick_db, sd->status.char_id, log_picktype2char(type), nameid, amount, mapindex_id2name(sd->mapindex)) )
+ log_config.log_pick, sd->status.char_id, log_picktype2char(type), nameid, amount, mapindex_id2name(sd->mapindex)) )
{
Sql_ShowDebug(logmysql_handle);
return;
}
} else { //We log Extended item
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
- log_config.log_pick_db, sd->status.char_id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex)) )
+ log_config.log_pick, sd->status.char_id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex)) )
{
Sql_ShowDebug(logmysql_handle);
return;
@@ -237,14 +237,14 @@ void log_pick_mob(struct mob_data *md, e_log_pick_type type, int nameid, int amo
{
if( itm == NULL ) { //We log common item
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%s')",
- log_config.log_pick_db, md->class_, log_picktype2char(type), nameid, amount, mapname) )
+ log_config.log_pick, md->class_, log_picktype2char(type), nameid, amount, mapname) )
{
Sql_ShowDebug(logmysql_handle);
return;
}
} else { //We log Extended item
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
- log_config.log_pick_db, md->class_, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname) )
+ log_config.log_pick, md->class_, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname) )
{
Sql_ShowDebug(logmysql_handle);
return;
@@ -300,7 +300,7 @@ void log_zeny(struct map_session_data *sd, e_log_pick_type type, struct map_sess
if( log_config.sql_logs )
{
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
- log_config.log_zeny_db, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
+ log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
{
Sql_ShowDebug(logmysql_handle);
return;
@@ -334,7 +334,7 @@ void log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
if( log_config.sql_logs )
{
if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
- log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
+ log_config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
{
Sql_ShowDebug(logmysql_handle);
return;
@@ -370,7 +370,7 @@ void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message)
SqlStmt* stmt;
stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm_db, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
@@ -410,7 +410,7 @@ void log_npc(struct map_session_data* sd, const char* message)
{
SqlStmt* stmt;
stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc_db, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
@@ -456,7 +456,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
SqlStmt* stmt;
stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat_db, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
+ if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
@@ -522,6 +522,13 @@ int log_config_read(char *cfgName)
log_config.enable_logs = (e_log_pick_type)config_switch(w2);
} else if(strcmpi(w1,"sql_logs") == 0) {
log_config.sql_logs = (bool)config_switch(w2);
+#ifdef TXT_ONLY
+ if( log_config.sql_logs )
+ {
+ ShowWarning("log_config_read: SQL logging is not supported on this server.\n");
+ log_config.sql_logs = false;
+ }
+#endif
//start of common filter settings
} else if(strcmpi(w1,"rare_items_log") == 0) {
log_config.rare_items_log = (atoi(w2));
@@ -548,68 +555,20 @@ int log_config_read(char *cfgName)
log_config.mvpdrop = config_switch(w2);
} else if(strcmpi(w1,"log_chat_woe_disable") == 0) {
log_config.log_chat_woe_disable = (bool)config_switch(w2);
- }
-
-#ifndef TXT_ONLY
- else if(strcmpi(w1, "log_branch_db") == 0) {
- strcpy(log_config.log_branch_db, w2);
- if(log_config.branch == 1)
- ShowNotice("Logging Dead Branch Usage to table `%s`\n", w2);
+ } else if(strcmpi(w1, "log_branch_db") == 0) {
+ safestrncpy(log_config.log_branch, w2, sizeof(log_config.log_branch));
} else if(strcmpi(w1, "log_pick_db") == 0) {
- strcpy(log_config.log_pick_db, w2);
- if(log_config.filter)
- ShowNotice("Logging Item Picks to table `%s`\n", w2);
+ safestrncpy(log_config.log_pick, w2, sizeof(log_config.log_pick));
} else if(strcmpi(w1, "log_zeny_db") == 0) {
- strcpy(log_config.log_zeny_db, w2);
- if(log_config.zeny == 1)
- ShowNotice("Logging Zeny to table `%s`\n", w2);
+ safestrncpy(log_config.log_zeny, w2, sizeof(log_config.log_zeny));
} else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
- strcpy(log_config.log_mvpdrop_db, w2);
- if(log_config.mvpdrop == 1)
- ShowNotice("Logging MVP Drops to table `%s`\n", w2);
+ safestrncpy(log_config.log_mvpdrop, w2, sizeof(log_config.log_mvpdrop));
} else if(strcmpi(w1, "log_gm_db") == 0) {
- strcpy(log_config.log_gm_db, w2);
- if(log_config.gm > 0)
- ShowNotice("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
+ safestrncpy(log_config.log_gm, w2, sizeof(log_config.log_gm));
} else if(strcmpi(w1, "log_npc_db") == 0) {
- strcpy(log_config.log_npc_db, w2);
- if(log_config.npc > 0)
- ShowNotice("Logging NPC 'logmes' to table `%s`\n", w2);
+ safestrncpy(log_config.log_npc, w2, sizeof(log_config.log_npc));
} else if(strcmpi(w1, "log_chat_db") == 0) {
- strcpy(log_config.log_chat_db, w2);
- if(log_config.chat > 0)
- ShowNotice("Logging CHAT to table `%s`\n", w2);
- }
-#endif
-
- else if(strcmpi(w1, "log_branch_file") == 0) {
- strcpy(log_config.log_branch, w2);
- if(log_config.branch > 0 && !log_config.sql_logs)
- ShowNotice("Logging Dead Branch Usage to file `%s`\n", w2);
- } else if(strcmpi(w1, "log_pick_file") == 0) {
- strcpy(log_config.log_pick, w2);
- if(log_config.filter > 0 && !log_config.sql_logs)
- ShowNotice("Logging Item Picks to file `%s`\n", w2);
- } else if(strcmpi(w1, "log_zeny_file") == 0) {
- strcpy(log_config.log_zeny, w2);
- if(log_config.zeny > 0 && !log_config.sql_logs)
- ShowNotice("Logging Zeny to file `%s`\n", w2);
- } else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
- strcpy(log_config.log_mvpdrop, w2);
- if(log_config.mvpdrop > 0 && !log_config.sql_logs)
- ShowNotice("Logging MVP Drops to file `%s`\n", w2);
- } else if(strcmpi(w1, "log_gm_file") == 0) {
- strcpy(log_config.log_gm, w2);
- if(log_config.gm > 0 && !log_config.sql_logs)
- ShowNotice("Logging GM Level %d Commands to file `%s`\n", log_config.gm, w2);
- } else if(strcmpi(w1, "log_npc_file") == 0) {
- strcpy(log_config.log_npc, w2);
- if(log_config.npc > 0 && !log_config.sql_logs)
- ShowNotice("Logging NPC 'logmes' to file `%s`\n", w2);
- } else if(strcmpi(w1, "log_chat_file") == 0) {
- strcpy(log_config.log_chat, w2);
- if(log_config.chat > 0 && !log_config.sql_logs)
- ShowNotice("Logging CHAT to file `%s`\n", w2);
+ safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
//support the import command, just like any other config
} else if(strcmpi(w1,"import") == 0) {
log_config_read(w2);
@@ -618,5 +577,40 @@ int log_config_read(char *cfgName)
}
fclose(fp);
+
+ if( --count == 0 )
+ {// report final logging state
+ const char* target = log_config.sql_logs ? "table" : "file";
+
+ if( log_config.enable_logs && log_config.filter )
+ {
+ ShowInfo("Logging item transactions to %s '%s'.\n", target, log_config.log_pick);
+ }
+ if( log_config.branch )
+ {
+ ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, log_config.log_pick);
+ }
+ if( log_config.chat )
+ {
+ ShowInfo("Logging chat to %s '%s'.\n", target, log_config.log_chat);
+ }
+ if( log_config.gm )
+ {
+ ShowInfo("Logging gm commands to %s '%s'.\n", target, log_config.log_gm);
+ }
+ if( log_config.mvpdrop )
+ {
+ ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, log_config.log_mvpdrop);
+ }
+ if( log_config.npc )
+ {
+ ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, log_config.log_npc);
+ }
+ if( log_config.zeny )
+ {
+ ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, log_config.log_zeny);
+ }
+ }
+
return 0;
}
diff --git a/src/map/log.h b/src/map/log.h
index 25a5ebf24..f52a386f5 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -73,9 +73,8 @@ extern struct Log_Config
bool sql_logs;
bool log_chat_woe_disable;
int rare_items_log,refine_items_log,price_items_log,amount_items_log; //for filter
- int branch, drop, mvpdrop, zeny, gm, npc, chat;
+ int branch, mvpdrop, zeny, gm, npc, chat;
char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64];
- char log_branch_db[32], log_pick_db[32], log_zeny_db[32], log_mvpdrop_db[32], log_gm_db[32], log_npc_db[32], log_chat_db[32];
}
log_config;