16 #define WIN32_LEAN_AND_MEAN
19 void al_print(LogLevel level
, FILE *logfile
, const char *fmt
, ...)
21 al::vector
<char> dynmsg
;
25 std::va_list args
, args2
;
28 const int msglen
{std::vsnprintf(str
, sizeof(stcmsg
), fmt
, args
)};
29 if(unlikely(msglen
>= 0 && static_cast<size_t>(msglen
) >= sizeof(stcmsg
)))
31 dynmsg
.resize(static_cast<size_t>(msglen
) + 1u);
33 std::vsnprintf(str
, dynmsg
.size(), fmt
, args2
);
38 if(gLogLevel
>= level
)
43 /* OutputDebugStringW has no 'level' property to distinguish between
44 * informational, warning, or error debug messages. So only print them for
48 std::wstring wstr
{utf8_to_wstr(str
)};
49 OutputDebugStringW(wstr
.c_str());
56 #include <android/log.h>
59 void al_print(LogLevel level
, FILE *logfile
, const char *fmt
, ...)
61 al::vector
<char> dynmsg
;
65 std::va_list args
, args2
;
68 const int msglen
{std::vsnprintf(str
, sizeof(stcmsg
), fmt
, args
)};
69 if(unlikely(msglen
>= 0 && static_cast<size_t>(msglen
) >= sizeof(stcmsg
)))
71 dynmsg
.resize(static_cast<size_t>(msglen
) + 1u);
73 std::vsnprintf(str
, dynmsg
.size(), fmt
, args2
);
78 if(gLogLevel
>= level
)
80 std::fputs(str
, logfile
);
84 auto android_severity
= [](LogLevel l
) noexcept
88 case LogLevel::Trace
: return ANDROID_LOG_DEBUG
;
89 case LogLevel::Warning
: return ANDROID_LOG_WARN
;
90 case LogLevel::Error
: return ANDROID_LOG_ERROR
;
91 /* Should not happen. */
92 case LogLevel::Disable
:
95 return ANDROID_LOG_ERROR
;
97 __android_log_print(android_severity(level
), "openal", "%s", str
);