Android fixing logs
This commit is contained in:
parent
adf9871861
commit
9f812f0318
@ -94,17 +94,12 @@ void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, in
|
|||||||
if (!sound) {
|
if (!sound) {
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "Game",
|
|
||||||
"AudioPlayerAsync::playSoundAsync step x2");
|
|
||||||
std::vector<char> buffer = FRG::readFile(filePath);
|
std::vector<char> buffer = FRG::readFile(filePath);
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "Game",
|
|
||||||
"AudioPlayerAsync::playSoundAsync step x3");
|
|
||||||
FRG::logger() << "Failed to read sound file into buffer: " << filePath << std::endl;
|
FRG::logger() << "Failed to read sound file into buffer: " << filePath << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "Game",
|
|
||||||
"AudioPlayerAsync::playSoundAsync step x4");
|
|
||||||
SDL_RWops* rw = SDL_RWFromMem(buffer.data(), buffer.size());
|
SDL_RWops* rw = SDL_RWFromMem(buffer.data(), buffer.size());
|
||||||
if (!rw) {
|
if (!rw) {
|
||||||
FRG::logger() << "Failed to create RWops from buffer for " << filePath << ": " << SDL_GetError() << std::endl;
|
FRG::logger() << "Failed to create RWops from buffer for " << filePath << ": " << SDL_GetError() << std::endl;
|
||||||
|
|||||||
@ -441,7 +441,11 @@ namespace FRG
|
|||||||
g_logFile.open(logPath, std::ios::out | std::ios::trunc);
|
g_logFile.open(logPath, std::ios::out | std::ios::trunc);
|
||||||
|
|
||||||
if (g_logFile.is_open()) {
|
if (g_logFile.is_open()) {
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
g_teeBuffer = std::make_unique<TeeBuffer>(&g_androidLogBuffer, g_logFile.rdbuf());
|
||||||
|
#else
|
||||||
g_teeBuffer = std::make_unique<TeeBuffer>(std::cout.rdbuf(), g_logFile.rdbuf());
|
g_teeBuffer = std::make_unique<TeeBuffer>(std::cout.rdbuf(), g_logFile.rdbuf());
|
||||||
|
#endif
|
||||||
g_teeStream = std::make_unique<std::ostream>(g_teeBuffer.get());
|
g_teeStream = std::make_unique<std::ostream>(g_teeBuffer.get());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -459,8 +463,11 @@ namespace FRG
|
|||||||
if (g_teeStream) {
|
if (g_teeStream) {
|
||||||
return *g_teeStream;
|
return *g_teeStream;
|
||||||
}
|
}
|
||||||
// Фолбэк на стандартный вывод, если файл по какой-то причине не открылся
|
#ifdef __ANDROID__
|
||||||
|
return g_androidStream;
|
||||||
|
#else
|
||||||
return std::cout;
|
return std::cout;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Если логирование отключено, возвращаем заглушку.
|
// Если логирование отключено, возвращаем заглушку.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user