mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Separate micellaneous functions.
This commit is contained in:
parent
76621cf946
commit
9d254a805c
@ -450,6 +450,7 @@
|
||||
<Unit filename="../source/Core.hpp" />
|
||||
<Unit filename="../source/CoreEntity.cpp" />
|
||||
<Unit filename="../source/CoreEvents.cpp" />
|
||||
<Unit filename="../source/CoreFuncs.cpp" />
|
||||
<Unit filename="../source/CoreUtils.cpp" />
|
||||
<Unit filename="../source/Entity/Blip.cpp" />
|
||||
<Unit filename="../source/Entity/Blip.hpp" />
|
||||
@ -517,7 +518,6 @@
|
||||
<Unit filename="../source/Logger.cpp" />
|
||||
<Unit filename="../source/Logger.hpp" />
|
||||
<Unit filename="../source/Main.cpp" />
|
||||
<Unit filename="../source/Misc.cpp" />
|
||||
<Unit filename="../source/Misc/Functions.cpp" />
|
||||
<Unit filename="../source/Misc/Functions.hpp" />
|
||||
<Unit filename="../source/Misc/Model.cpp" />
|
||||
|
@ -1,11 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqstdstring.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -149,48 +145,4 @@ void Register_Core(HSQUIRRELVM vm)
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Was the message value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
return sq_throwerror(vm, "Missing message value");
|
||||
}
|
||||
// Attempt to generate the string value
|
||||
StackStrF val(vm, 2);
|
||||
// Have we failed to retrieve the string?
|
||||
if (SQ_FAILED(val.mRes))
|
||||
{
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
// Forward the resulted string value to the logger
|
||||
Logger::Get().Write(L, S, "%s", val.mPtr);
|
||||
// This function does not return a value
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Log(HSQUIRRELVM vm)
|
||||
{
|
||||
RootTable(vm)
|
||||
.Bind(_SC("SqLog"), Table(vm)
|
||||
.SquirrelFunc(_SC("Dbg"), &LogBasicMessage< LOGL_DBG, false >)
|
||||
.SquirrelFunc(_SC("Usr"), &LogBasicMessage< LOGL_USR, false >)
|
||||
.SquirrelFunc(_SC("Scs"), &LogBasicMessage< LOGL_SCS, false >)
|
||||
.SquirrelFunc(_SC("Inf"), &LogBasicMessage< LOGL_INF, false >)
|
||||
.SquirrelFunc(_SC("Wrn"), &LogBasicMessage< LOGL_WRN, false >)
|
||||
.SquirrelFunc(_SC("Err"), &LogBasicMessage< LOGL_ERR, false >)
|
||||
.SquirrelFunc(_SC("Ftl"), &LogBasicMessage< LOGL_FTL, false >)
|
||||
.SquirrelFunc(_SC("SDbg"), &LogBasicMessage< LOGL_DBG, true >)
|
||||
.SquirrelFunc(_SC("SUsr"), &LogBasicMessage< LOGL_USR, true >)
|
||||
.SquirrelFunc(_SC("SScs"), &LogBasicMessage< LOGL_SCS, true >)
|
||||
.SquirrelFunc(_SC("SInf"), &LogBasicMessage< LOGL_INF, true >)
|
||||
.SquirrelFunc(_SC("SWrn"), &LogBasicMessage< LOGL_WRN, true >)
|
||||
.SquirrelFunc(_SC("SErr"), &LogBasicMessage< LOGL_ERR, true >)
|
||||
.SquirrelFunc(_SC("SFtl"), &LogBasicMessage< LOGL_FTL, true >)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
@ -1,5 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Logger.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <ctime>
|
||||
@ -596,4 +597,48 @@ void OutputError(CCStr msg, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Was the message value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
return sq_throwerror(vm, "Missing message value");
|
||||
}
|
||||
// Attempt to generate the string value
|
||||
StackStrF val(vm, 2);
|
||||
// Have we failed to retrieve the string?
|
||||
if (SQ_FAILED(val.mRes))
|
||||
{
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
// Forward the resulted string value to the logger
|
||||
Logger::Get().Write(L, S, "%s", val.mPtr);
|
||||
// This function does not return a value
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Log(HSQUIRRELVM vm)
|
||||
{
|
||||
RootTable(vm)
|
||||
.Bind(_SC("SqLog"), Table(vm)
|
||||
.SquirrelFunc(_SC("Dbg"), &LogBasicMessage< LOGL_DBG, false >)
|
||||
.SquirrelFunc(_SC("Usr"), &LogBasicMessage< LOGL_USR, false >)
|
||||
.SquirrelFunc(_SC("Scs"), &LogBasicMessage< LOGL_SCS, false >)
|
||||
.SquirrelFunc(_SC("Inf"), &LogBasicMessage< LOGL_INF, false >)
|
||||
.SquirrelFunc(_SC("Wrn"), &LogBasicMessage< LOGL_WRN, false >)
|
||||
.SquirrelFunc(_SC("Err"), &LogBasicMessage< LOGL_ERR, false >)
|
||||
.SquirrelFunc(_SC("Ftl"), &LogBasicMessage< LOGL_FTL, false >)
|
||||
.SquirrelFunc(_SC("SDbg"), &LogBasicMessage< LOGL_DBG, true >)
|
||||
.SquirrelFunc(_SC("SUsr"), &LogBasicMessage< LOGL_USR, true >)
|
||||
.SquirrelFunc(_SC("SScs"), &LogBasicMessage< LOGL_SCS, true >)
|
||||
.SquirrelFunc(_SC("SInf"), &LogBasicMessage< LOGL_INF, true >)
|
||||
.SquirrelFunc(_SC("SWrn"), &LogBasicMessage< LOGL_WRN, true >)
|
||||
.SquirrelFunc(_SC("SErr"), &LogBasicMessage< LOGL_ERR, true >)
|
||||
.SquirrelFunc(_SC("SFtl"), &LogBasicMessage< LOGL_FTL, true >)
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
Loading…
Reference in New Issue
Block a user