Skip to content

Commit

Permalink
日志格式化使用fmt
Browse files Browse the repository at this point in the history
1、优化日志库
2、日志格式化使用fmt
  • Loading branch information
xiyoo0812 committed Sep 22, 2023
1 parent 567c7e9 commit 452352b
Show file tree
Hide file tree
Showing 131 changed files with 875 additions and 959 deletions.
1 change: 1 addition & 0 deletions core/luabus/luabus.mak
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MYCFLAGS += -Wsign-compare
MYCFLAGS += -Wno-sign-compare
MYCFLAGS += -Wno-unused-variable
MYCFLAGS += -Wno-unused-parameter
MYCFLAGS += -Wno-unused-but-set-variable
MYCFLAGS += -Wno-unused-but-set-parameter
MYCFLAGS += -Wno-unknown-pragmas

Expand Down
2 changes: 1 addition & 1 deletion core/luabus/luabus.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\..\extend\lua\lua;..\..\extend\ltimer\ltimer;..\..\extend\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion core/quanta/quanta.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\..\extend\lua\lua;..\..\extend\fmt\include;..\..\extend\luakit\include;..\..\extend\lualog\lualog;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;FMT_HEADER_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/laoi/laoi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lbson/lbson.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lcodec/lcodec.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lcrypt/lcrypt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LCRYPT_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lcurl/lcurl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;.\;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/ldetour/ldetour.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>src\detour;..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/ljson/ljson.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lmake/tmpl/vcxproj.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>{{%= FMT_INCLUDES %}};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;{{%= FMT_DEFINES %}};%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lstdfs/lstdfs.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/ltimer/ltimer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lua/lua.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>.\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MAKE_LUA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lua/luac.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>.\lua;.\luac;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MAKE_LUAC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lua/lualib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>.\lua;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lualog/lualog.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\fmt\include;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;FMT_HEADER_ONLY;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
79 changes: 73 additions & 6 deletions extend/lualog/lualog/lualog.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
#define LUA_LIB
#include "logger.h"

using namespace std;
using namespace luakit;

namespace logger {

thread_local luabuf buf;
string read_args(lua_State* L, int flag, int index) {
switch (lua_type(L, index)) {
case LUA_TNIL: return "nil";
case LUA_TTHREAD: return "thread";
case LUA_TFUNCTION: return "function";
case LUA_TUSERDATA: return "userdata";
case LUA_TLIGHTUSERDATA: return "userdata";
case LUA_TSTRING: return lua_tostring(L, index);
case LUA_TBOOLEAN: return (lua_tointeger(L, index) == 1) ? "true" : "false";
case LUA_TTABLE:
if ((flag & 0x01) == 0x01) {
buf.clean();
serialize_one(L, &buf, index, 1, (flag & 0x02) == 0x02);
return string((char*)buf.head(), buf.size());
}
return luaL_tolstring(L, index, nullptr);
case LUA_TNUMBER:
if (lua_isinteger(L, index)) {
return fmt::format("{}", lua_tointeger(L, index));
}
return fmt::format("{}", lua_tonumber(L, index));
}
return "unsuppert data type";
}

int zformat(lua_State* L, log_level lvl, vstring tag, vstring feature, vstring msg) {
get_logger()->output(lvl, msg, tag, feature);
if (lvl == log_level::LOG_LEVEL_FATAL) {
lua_pushlstring(L, msg.data(), msg.size());
return 1;
}
return 0;
}

template<size_t... integers>
int tformat(lua_State* L, log_level lvl, vstring tag, vstring feature, int flag, vstring vfmt, std::index_sequence<integers...>&&) {
try {
auto msg = fmt::format(vfmt, read_args(L, flag, integers + 6)...);
return zformat(L, lvl, tag, feature, msg);
} catch (const exception& e) {
luaL_error(L, "log format failed: %s!", e.what());
}
return 0;
}

luakit::lua_table open_lualog(lua_State* L) {
luakit::kit_state kit_state(L);
auto lualog = kit_state.new_table();
Expand All @@ -14,6 +63,30 @@ namespace logger {
"ERROR", log_level::LOG_LEVEL_ERROR,
"FATAL", log_level::LOG_LEVEL_FATAL
);

lualog.set_function("print", [](lua_State* L) {
log_level lvl = (log_level)lua_tointeger(L, 1);
if (get_logger()->is_filter(lvl)) return 0;
size_t flag = lua_tointeger(L, 2);
vstring tag = lua_to_native<vstring>(L, 3);
vstring feature = lua_to_native<vstring>(L, 4);
vstring vfmt = lua_to_native<vstring>(L, 5);
int arg_num = lua_gettop(L) - 5;
switch (arg_num) {
case 0: return zformat(L, lvl, tag, feature, vfmt);
case 1: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<1>{});
case 2: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<2>{});
case 3: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<3>{});
case 4: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<4>{});
case 5: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<5>{});
case 6: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<6>{});
case 7: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<7>{});
case 8: return tformat(L, lvl, tag, feature, flag, vfmt, make_index_sequence<8>{});
default: luaL_error(L, "log format args is more than 8!"); break;
}
return 0;
});

lualog.set_function("daemon", [](bool status) { get_logger()->daemon(status); });
lualog.set_function("set_max_line", [](size_t line) { get_logger()->set_max_line(line); });
lualog.set_function("set_clean_time", [](size_t time) { get_logger()->set_clean_time(time); });
Expand All @@ -28,12 +101,6 @@ namespace logger {
lualog.set_function("add_dest", [](vstring feature, vstring log_path) { return get_logger()->add_dest(feature, log_path); });
lualog.set_function("add_file_dest", [](vstring feature, vstring fname) { return get_logger()->add_file_dest(feature, fname); });
lualog.set_function("set_dest_clean_time", [](vstring feature, size_t time) { get_logger()->set_dest_clean_time(feature, time); });
lualog.set_function("info", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_INFO, msg, tag, feature); });
lualog.set_function("warn", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_WARN, msg, tag, feature); });
lualog.set_function("dump", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_DUMP, msg, tag, feature); });
lualog.set_function("debug", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_DEBUG, msg, tag, feature); });
lualog.set_function("error", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_ERROR, msg, tag, feature); });
lualog.set_function("fatal", [](vstring msg, vstring tag, vstring feature) { get_logger()->output(log_level::LOG_LEVEL_FATAL, msg, tag, feature); });
lualog.set_function("option", [](vstring log_path, vstring service, vstring index) { get_logger()->option(log_path, service, index); });
return lualog;
}
Expand Down
2 changes: 1 addition & 1 deletion extend/luapb/luapb.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/luaxlsx/luaxlsx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/lworker/lworker.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>..\lua\lua;..\fmt\include;..\ltimer\ltimer;..\luakit\include;$(SolutionDir)extend\mimalloc\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;FMT_HEADER_ONLY;LUA_BUILD_AS_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
2 changes: 1 addition & 1 deletion extend/mimalloc/mimalloc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
Expand Down
8 changes: 4 additions & 4 deletions script/agent/cache_agent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
function CacheAgent:load(primary_id, sheet_name)
local ok, code, row_data = router_mgr:call_cache_hash(primary_id, "rpc_cache_load", primary_id, sheet_name)
if qfailed(code, ok) then
log_err("[CacheAgent][load] code=%s, pkey=%s, sheet_name=%s", code, primary_id, sheet_name)
log_err("[CacheAgent][load] code={}, pkey={}, sheet_name={}", code, primary_id, sheet_name)
return ok and code or RPC_FAILED
end
return code, row_data
Expand All @@ -25,7 +25,7 @@ end
function CacheAgent:update_field(primary_id, sheet_name, field, field_data)
local ok, code = router_mgr:call_cache_hash(primary_id, "rpc_cache_update_field", primary_id, sheet_name, field, field_data)
if qfailed(code, ok) then
log_err("[CacheAgent][update_field] faild: code=%s, sheet_name=%s, primary_id=%s", code, sheet_name, primary_id)
log_err("[CacheAgent][update_field] faild: code={}, sheet_name={}, primary_id={}", code, sheet_name, primary_id)
return ok and code or RPC_FAILED
end
return code
Expand All @@ -35,7 +35,7 @@ end
function CacheAgent:remove_field(primary_id, sheet_name, field)
local ok, code = router_mgr:call_cache_hash(primary_id, "rpc_cache_remove_field", primary_id, sheet_name, field)
if qfailed(code, ok) then
log_err("[CacheAgent][remove_field] faild: code=%s, sheet_name=%s, primary_id=%s", code, sheet_name, primary_id)
log_err("[CacheAgent][remove_field] faild: code={}, sheet_name={}, primary_id={}", code, sheet_name, primary_id)
return ok and code or RPC_FAILED
end
return code
Expand All @@ -45,7 +45,7 @@ end
function CacheAgent:delete(primary_id, sheet_name)
local ok, code = router_mgr:call_cache_hash(primary_id, "rpc_cache_delete", primary_id, sheet_name)
if qfailed(code, ok) then
log_err("[CacheAgent][delete] faild: code=%s, sheet_name=%s, primary_id=%s", code, sheet_name, primary_id)
log_err("[CacheAgent][delete] faild: code={}, sheet_name={}, primary_id={}", code, sheet_name, primary_id)
return ok and code or RPC_FAILED
end
return code
Expand Down
Loading

0 comments on commit 452352b

Please sign in to comment.