summaryrefslogtreecommitdiff
path: root/src/map/log.c
diff options
context:
space:
mode:
authorLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-23 20:20:06 +0000
committerLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-23 20:20:06 +0000
commitbe12ec3ffb1632d8f9f7727ae9a17ea137bde375 (patch)
tree821d07f7d405ec9c89010cadac06395ea5ca622b /src/map/log.c
parent3a582ad4976cd2672e22a33cd738346e5e09a9bd (diff)
downloadhercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.gz
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.bz2
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.tar.xz
hercules-be12ec3ffb1632d8f9f7727ae9a17ea137bde375.zip
Added LOGMES script command
implemented an example: kafra_bank.txt git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@759 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/log.c')
-rw-r--r--src/map/log.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/map/log.c b/src/map/log.c
index be8280b7f..770d6acca 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -340,6 +340,34 @@ int log_atcommand(struct map_session_data *sd, const char *message)
return 0;
}
+int log_npc(struct map_session_data *sd, const char *message)
+{ //[Lupus]
+ FILE *logfp;
+ if(log_config.enable_logs <= 0)
+ return 0;
+ nullpo_retr(0, sd);
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", log_config.log_npc_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->mapname, message);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_npc,"a+")) != NULL) {
+ char timestring[255];
+ time_t curtime;
+ time(&curtime);
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
+ #endif
+ return 0;
+}
+
int log_config_read(char *cfgName)
{
char line[1024], w1[1024], w2[1024];
@@ -385,6 +413,8 @@ int log_config_read(char *cfgName)
log_config.zeny = (atoi(w2));
} else if(strcmpi(w1,"log_gm") == 0) {
log_config.gm = (atoi(w2));
+ } else if(strcmpi(w1,"log_npc") == 0) {
+ log_config.npc = (atoi(w2));
}
else if(strcmpi(w1, "log_branch_db") == 0) {
@@ -428,6 +458,10 @@ int log_config_read(char *cfgName)
strcpy(log_config.log_gm_db, w2);
if(log_config.gm > 0)
printf("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
+ } else if(strcmpi(w1, "log_npc_db") == 0) {
+ strcpy(log_config.log_npc_db, w2);
+ if(log_config.npc > 0)
+ printf("Logging NPC 'logmes' to table `%s`\n", w2);
}
else if(strcmpi(w1, "log_branch") == 0) {
@@ -471,6 +505,10 @@ int log_config_read(char *cfgName)
strcpy(log_config.log_gm, w2);
if(log_config.gm > 0)
printf("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
+ } else if(strcmpi(w1, "log_npc") == 0) {
+ strcpy(log_config.log_npc, w2);
+ if(log_config.npc > 0)
+ printf("Logging NPC 'logmes' to file `%s`.txt\n", w2);
//support the import command, just like any other config
} else if(strcmpi(w1,"import")==0){
log_config_read(w2);