/// logs used atcommands void log_atcommand(struct map_session_data* sd, const char* message) { nullpo_retv(sd); if(!logs->config.commands || !pc_should_log_commands(sd)) return; logs->atcommand_sub(sd,message); }
/// logs used atcommands void log_atcommand(struct map_session_data* sd, const char* message) { nullpo_retv(sd); if( !log_config.commands || !pc_should_log_commands(sd) ) return; if( log_config.sql_logs ) { #ifdef BETA_THREAD_TEST char entry[512]; int e_length = 0; e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', '%s', '%s', '%s')", log_config.log_gm, sd->status.account_id, sd->status.char_id, sd->status.name ,mapindex_id2name(sd->mapindex), message); queryThread_log(entry,e_length); #else 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, 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) ) { SqlStmt_ShowDebug(stmt); SqlStmt_Free(stmt); return; } SqlStmt_Free(stmt); #endif } else { char timestring[255]; time_t curtime; FILE* logfp; if( ( logfp = fopen(log_config.log_gm, "a") ) == NULL ) return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message); fclose(logfp); } }