summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/ManualBindings.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index b0c18b32e..7f7cb8ea9 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -33,7 +33,6 @@
#include "../HTTP/UrlParser.h"
#include "../Item.h"
#include "../LineBlockTracer.h"
-#include "../Logger.h"
#include "../Server.h"
#include "../Root.h"
#include "../StringCompression.h"
@@ -368,23 +367,19 @@ static int tolua_StringSplitAndTrim(lua_State * tolua_S)
/** Retrieves the log message from the first param on the Lua stack.
Can take either a string or a cCompositeChat.
*/
-static AString GetLogMessage(lua_State * tolua_S)
+static void LogFromLuaStack(lua_State * tolua_S, eLogLevel a_LogLevel)
{
tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{
- return static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
+ auto Msg = static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
+ Logger::LogSimple(Msg, a_LogLevel);
+ return;
}
- else
- {
- size_t len = 0;
- const char * str = lua_tolstring(tolua_S, 1, &len);
- if (str != nullptr)
- {
- return AString(str, len);
- }
- }
- return "";
+
+ size_t len = 0;
+ const char * str = lua_tolstring(tolua_S, 1, &len);
+ Logger::LogSimple(std::string_view(str, len), a_LogLevel);
}
@@ -406,11 +401,13 @@ static int tolua_LOG(lua_State * tolua_S)
tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{
- LogLevel = cCompositeChat::MessageTypeToLogLevel(static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
+ LogLevel = cCompositeChat::MessageTypeToLogLevel(
+ static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType()
+ );
}
// Log the message:
- cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S), LogLevel);
+ LogFromLuaStack(tolua_S, LogLevel);
return 0;
}
@@ -428,7 +425,7 @@ static int tolua_LOGINFO(lua_State * tolua_S)
return 0;
}
- cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S), eLogLevel::Info);
+ LogFromLuaStack(tolua_S, eLogLevel::Info);
return 0;
}
@@ -446,7 +443,7 @@ static int tolua_LOGWARN(lua_State * tolua_S)
return 0;
}
- cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S), eLogLevel::Warning);
+ LogFromLuaStack(tolua_S, eLogLevel::Warning);
return 0;
}
@@ -464,7 +461,7 @@ static int tolua_LOGERROR(lua_State * tolua_S)
return 0;
}
- cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S), eLogLevel::Error);
+ LogFromLuaStack(tolua_S, eLogLevel::Error);
return 0;
}