Bladeren bron

nx: add a logger.

legacy
Sam Hocevar 5 jaren geleden
bovenliggende
commit
e7b1f4c56b
8 gewijzigde bestanden met toevoegingen van 47 en 22 verwijderingen
  1. +2
    -2
      build/msbuild/lol.rules.props
  2. +6
    -3
      build/msbuild/lol.vars.props
  3. +4
    -0
      src/application/application.cpp
  4. +13
    -9
      src/base/log.cpp
  5. +10
    -0
      src/lol-core.vcxproj
  6. +4
    -0
      src/lol-core.vcxproj.filters
  7. +7
    -7
      src/lol/base/log.h
  8. +1
    -1
      src/private/nx

+ 2
- 2
build/msbuild/lol.rules.props Bestand weergeven

@@ -65,7 +65,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<Optimization>Disabled</Optimization>
<RuntimeLibrary Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">MultiThreadedDebugDLL</RuntimeLibrary>
<PreprocessorDefinitions>_DEBUG;LOL_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;LOL_BUILD_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Release'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -78,7 +78,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<PreprocessorDefinitions>NDEBUG;LOL_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;LOL_BUILD_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>

<Link Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">


+ 6
- 3
build/msbuild/lol.vars.props Bestand weergeven

@@ -143,14 +143,17 @@
<BuildMacro Include="XinputLibs"><Value>$(XinputLibs)</Value></BuildMacro>
<BuildMacro Include="XinputDeps"><Value>$(XinputDeps)</Value></BuildMacro>
<BuildMacro Include="Win32Defines"><Value>$(Win32Defines)</Value></BuildMacro>
<BuildMacro Include="Nx64Deps"><Value>$(Nx64Deps)</Value></BuildMacro>
<BuildMacro Include="Nx64Libs"><Value>$(Nx64Libs)</Value></BuildMacro>
<BuildMacro Include="Nx64Defines"><Value>$(Nx64Defines)</Value></BuildMacro>
<BuildMacro Include="OrbisDeps"><Value>$(OrbisDeps)</Value></BuildMacro>
<BuildMacro Include="OrbisLibs"><Value>$(OrbisLibs)</Value></BuildMacro>
<BuildMacro Include="OrbisDefines"><Value>$(OrbisDefines)</Value></BuildMacro>
</ItemGroup>

<!--
- Secret stuff for platforms under NDA
-->
<Import Condition="Exists('$(LolDir)\src\private\nx\msbuild\nx.vars.props')"
Project="$(LolDir)\src\private\nx\msbuild\nx.vars.props" />

<PropertyGroup>
<BinDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\binaries</BinDir>
<BinDir Condition="!Exists('$(SolutionDir)\lol')">$(LolDir)\binaries</BinDir>


+ 4
- 0
src/application/application.cpp Bestand weergeven

@@ -20,6 +20,8 @@

#if __ANDROID__
# include "application/android-app.h"
#elif __NX__
# include "private/nx/nx-app.h"
#elif LOL_USE_SDL
# include "application/sdl-app.h"
#elif HAVE_GLES_2X
@@ -136,6 +138,8 @@ class ApplicationData

#if __ANDROID__
AndroidApp app;
#elif __NX__
NxApp app;
#elif LOL_USE_SDL
sdl::app app;
#elif HAVE_GLES_2X


+ 13
- 9
src/base/log.cpp Bestand weergeven

@@ -21,9 +21,11 @@
# undef WIN32_LEAN_AND_MEAN
#endif

#if defined(__ANDROID__)
#if __ANDROID__
# include <android/log.h>
# include <unistd.h> /* for gettid() */
#elif __NX__
# include "../private/nx/nx-log.h"
#else
# include <cstdarg>
#endif
@@ -39,7 +41,7 @@ void msg::debug(char const *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
helper(MessageType::Debug, fmt, ap);
helper(message_type::debug, fmt, ap);
va_end(ap);
}

@@ -47,7 +49,7 @@ void msg::info(char const *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
helper(MessageType::Info, fmt, ap);
helper(message_type::info, fmt, ap);
va_end(ap);
}

@@ -55,7 +57,7 @@ void msg::warn(char const *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
helper(MessageType::Warning, fmt, ap);
helper(message_type::warning, fmt, ap);
va_end(ap);
}

@@ -63,7 +65,7 @@ void msg::error(char const *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
helper(MessageType::Error, fmt, ap);
helper(message_type::error, fmt, ap);
va_end(ap);
}

@@ -71,12 +73,12 @@ void msg::error(char const *fmt, ...)
* Private helper function
*/

void msg::helper(MessageType type, char const *fmt, va_list ap)
void msg::helper(message_type type, char const *fmt, va_list ap)
{
/* Unless this is a debug build, ignore debug messages unless
* the LOL_DEBUG environment variable is set. */
#if !defined LOL_BUILD_DEBUG
if (type == MessageType::Debug)
#if !defined LOL_BUILD_DEBUG && !_DEBUG
if (type == message_type::debug)
{
static char const *var = getenv("LOL_DEBUG");
static bool const disable_debug = !var || !var[0];
@@ -85,7 +87,7 @@ void msg::helper(MessageType type, char const *fmt, va_list ap)
}
#endif

#if defined __ANDROID__
#if __ANDROID__
static int const prio[] =
{
ANDROID_LOG_DEBUG,
@@ -97,6 +99,8 @@ void msg::helper(MessageType type, char const *fmt, va_list ap)
std::string buf = vformat(fmt, ap);
__android_log_print(prio[(int)type], "LOL", "[%d] %s", (int)gettid(), &buf[0]);

#elif __NX__
nx::helper(type, fmt, ap);
#else
static char const * const prefix[] =
{


+ 10
- 0
src/lol-core.vcxproj Bestand weergeven

@@ -90,6 +90,7 @@
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions);LOL_INPUT_V2</PreprocessorDefinitions>
<OptimizationLevel Condition="'$(Configuration)|$(Platform)'=='Debug|NX64'">O1</OptimizationLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
@@ -186,6 +187,9 @@
<ClCompile Include="private\nx\nx-app.cpp">
<ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="private\nx\nx-log.cpp">
<ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="profiler.cpp" />
<ClCompile Include="scene.cpp" />
<ClCompile Include="sprite.cpp" />
@@ -303,6 +307,12 @@
<ClInclude Include="messageservice.h" />
<ClInclude Include="numeric.h" />
<ClInclude Include="platform.h" />
<ClInclude Include="private\nx\nx-app.h">
<ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="private\nx\nx-log.h">
<ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="profiler.h" />
<ClInclude Include="scene.h" />
<ClInclude Include="sprite.h" />


+ 4
- 0
src/lol-core.vcxproj.filters Bestand weergeven

@@ -258,6 +258,8 @@
<ClCompile Include="3rdparty\imgui\imgui_widgets.cpp" />
<ClCompile Include="audio\audio.cpp" />
<ClCompile Include="audio\sample.cpp" />
<ClCompile Include="private\nx\nx-app.cpp" />
<ClCompile Include="private\nx\nx-log.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="application\application.h">
@@ -551,6 +553,8 @@
<ClInclude Include="lol\audio\audio.h">
<Filter>lol\audio</Filter>
</ClInclude>
<ClInclude Include="private\nx\nx-app.h" />
<ClInclude Include="private\nx\nx-log.h" />
</ItemGroup>
<ItemGroup>
<LolFxCompile Include="easymesh\shiny.lolfx">


+ 7
- 7
src/lol/base/log.h Bestand weergeven

@@ -32,16 +32,16 @@ public:
static void warn(char const *format, ...) LOL_ATTR_FORMAT(1, 2);
static void error(char const *format, ...) LOL_ATTR_FORMAT(1, 2);

private:
enum class MessageType
enum class message_type
{
Debug,
Info,
Warning,
Error
debug,
info,
warning,
error,
};

static void helper(MessageType type, char const *fmt, va_list ap);
private:
static void helper(message_type type, char const *fmt, va_list ap);
};

} /* namespace lol */


+ 1
- 1
src/private/nx

@@ -1 +1 @@
Subproject commit c2da1a20c6fa7b23efab7f1154d9d0ee49e7cd37
Subproject commit 840d8e587789c51e51f76c603eb4e1fb30581eae

Laden…
Annuleren
Opslaan