|
|
@@ -6,6 +6,7 @@
|
|
|
CPluginInstance::CPluginInstance()
|
|
|
: m_enable(false)
|
|
|
, m_redis_error_notified(false)
|
|
|
+ , m_debug_mode(0)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -606,7 +607,7 @@ void CPluginInstance::OnTradeRequestProcess(const IMTRequest* request, const IMT
|
|
|
m_redis_client->sync_commit();
|
|
|
auto reply = fut.get();
|
|
|
|
|
|
- m_api->LoggerOut(MTLogOK, L"request cache, key: %s", cache_key.c_str());
|
|
|
+ DebugOut(MTLogOK, L"request cache, key: %s", cache_key.c_str());
|
|
|
|
|
|
if (reply.ko()) return;
|
|
|
if (reply.is_null()) return;
|
|
|
@@ -634,7 +635,7 @@ void CPluginInstance::OnTradeRequestProcess(const IMTRequest* request, const IMT
|
|
|
m_redis_client->sync_commit();
|
|
|
auto ctx_reply = fut.get();
|
|
|
|
|
|
- m_api->LoggerOut(MTLogOK, L"request cache, key: %s", cache_key.c_str());
|
|
|
+ DebugOut(MTLogOK, L"request cache, key: %s", cache_key.c_str());
|
|
|
|
|
|
if (ctx_reply.ko()) return;
|
|
|
if (ctx_reply.is_null()) return;
|
|
|
@@ -647,7 +648,7 @@ void CPluginInstance::OnTradeRequestProcess(const IMTRequest* request, const IMT
|
|
|
context.volume += direction * order->VolumeCurrent();
|
|
|
context.position_id = position->Position();
|
|
|
|
|
|
- m_api->LoggerOut(MTLogOK, L"writeback context, key: %s, field: %s", orig_pos_buf, login_buf);
|
|
|
+ DebugOut(MTLogOK, L"writeback context, key: %s, field: %s", orig_pos_buf, login_buf);
|
|
|
|
|
|
// 写入
|
|
|
m_redis_client->hset(orig_pos_buf, login_buf, std::string((char*)&context, sizeof(position_context)), [this](cpp_redis::reply& r)
|
|
|
@@ -687,6 +688,9 @@ MTAPIRES CPluginInstance::LoadParam()
|
|
|
});
|
|
|
std::lock_guard<decltype(m_lock)> lk(m_lock);
|
|
|
|
|
|
+ // 首先一定要关闭debug mode,显示调用了debug mode才能生效
|
|
|
+ m_debug_mode = 0;
|
|
|
+
|
|
|
//m_api->LoggerOut(MTLogOK, L"Load redis server params");
|
|
|
|
|
|
if ((res = m_config->ParameterGet(L"Redis Server", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_STRING)
|
|
|
@@ -742,16 +746,16 @@ MTAPIRES CPluginInstance::LoadParam()
|
|
|
return(MT_RET_ERR_PARAMS);
|
|
|
}
|
|
|
m_trader = param->ValueInt();
|
|
|
- if ((res = m_config->ParameterGet(L"Step", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
|
|
|
- {
|
|
|
- return(MT_RET_ERR_PARAMS);
|
|
|
- }
|
|
|
- m_step = param->ValueInt();
|
|
|
- if ((res = m_config->ParameterGet(L"Tolerance", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
|
|
|
- {
|
|
|
- return(MT_RET_ERR_PARAMS);
|
|
|
- }
|
|
|
- m_tolerance = param->ValueInt();
|
|
|
+ //if ((res = m_config->ParameterGet(L"Step", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
|
|
|
+ //{
|
|
|
+ // return(MT_RET_ERR_PARAMS);
|
|
|
+ //}
|
|
|
+ //m_step = param->ValueInt();
|
|
|
+ //if ((res = m_config->ParameterGet(L"Tolerance", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
|
|
|
+ //{
|
|
|
+ // return(MT_RET_ERR_PARAMS);
|
|
|
+ //}
|
|
|
+ //m_tolerance = param->ValueInt();
|
|
|
if ((res = m_config->ParameterGet(L"Groups", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_STRING)
|
|
|
{
|
|
|
return(MT_RET_ERR_PARAMS);
|
|
|
@@ -762,6 +766,10 @@ MTAPIRES CPluginInstance::LoadParam()
|
|
|
// return(MT_RET_ERR_PARAMS);
|
|
|
//}
|
|
|
//m_logins = param->ValueString();
|
|
|
+ if ((res = m_config->ParameterGet(L"DebugMode", param)) == MT_RET_OK && param->Type() == IMTConParam::TYPE_INT)
|
|
|
+ {
|
|
|
+ m_debug_mode = param->ValueInt();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
res = LoadLogins();
|
|
|
@@ -799,7 +807,7 @@ MTAPIRES CPluginInstance::LoadLogins()
|
|
|
if (ret != MT_RET_OK) break;
|
|
|
if (CheckGroup(m_groups, group->Group()) == FALSE) continue;
|
|
|
|
|
|
- m_api->LoggerOut(MTLogOK, L"group %s matched config", group->Group());
|
|
|
+ DebugOut(MTLogOK, L"group %s matched config", group->Group());
|
|
|
groups.push_back(group->Group());
|
|
|
}
|
|
|
|
|
|
@@ -809,12 +817,12 @@ MTAPIRES CPluginInstance::LoadLogins()
|
|
|
UINT total_users = 0;
|
|
|
|
|
|
ret = m_api->UserLogins(group.c_str(), logins, total_users);
|
|
|
- m_api->LoggerOut(MTLogOK, L"add group %s, total users: %d", group.c_str(), total_users);
|
|
|
+ DebugOut(MTLogOK, L"add group %s, total users: %d", group.c_str(), total_users);
|
|
|
if (ret == MT_RET_OK && logins != nullptr)
|
|
|
{
|
|
|
for (int i = 0; i < total_users; ++i)
|
|
|
{
|
|
|
- m_api->LoggerOut(MTLogOK, L"add %d to list", logins[i]);
|
|
|
+ DebugOut(MTLogOK, L"add %d to list", logins[i]);
|
|
|
m_followers.push_back(logins[i]);
|
|
|
}
|
|
|
}
|