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 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 msglen
= std::vsnprintf(str
, dynmsg
.size(), fmt
, args2
);
38 std::wstring wstr
{utf8_to_wstr(str
)};
39 if(gLogLevel
>= level
)
41 fputws(wstr
.c_str(), logfile
);
44 OutputDebugStringW(wstr
.c_str());
50 #include <android/log.h>
53 void al_print(LogLevel level
, FILE *logfile
, const char *fmt
, ...)
55 al::vector
<char> dynmsg
;
59 std::va_list args
, args2
;
62 int msglen
{std::vsnprintf(str
, sizeof(stcmsg
), fmt
, args
)};
63 if UNLIKELY(msglen
>= 0 && static_cast<size_t>(msglen
) >= sizeof(stcmsg
))
65 dynmsg
.resize(static_cast<size_t>(msglen
) + 1u);
67 msglen
= std::vsnprintf(str
, dynmsg
.size(), fmt
, args2
);
72 if(gLogLevel
>= level
)
74 std::fputs(str
, logfile
);
78 auto android_severity
= [](LogLevel l
) noexcept
82 case LogLevel::Trace
: return ANDROID_LOG_DEBUG
;
83 case LogLevel::Warning
: return ANDROID_LOG_WARN
;
84 case LogLevel::Error
: return ANDROID_LOG_ERROR
;
85 /* Should not happen. */
86 case LogLevel::Disable
:
89 return ANDROID_LOG_ERROR
;
91 __android_log_print(android_severity(level
), "openal", "%s", str
);