Implemented stdout, stderr, debug writers.

This commit is contained in:
Branimir Karadžić
2017-06-08 21:28:12 -07:00
parent aa6ce5a2e5
commit 7eb1bb115f
5 changed files with 235 additions and 85 deletions

View File

@@ -4,8 +4,9 @@
*/
#include <bx/debug.h>
#include <bx/string.h> // isPrint
#include <inttypes.h> // PRIx*
#include <bx/string.h> // isPrint
#include <bx/readerwriter.h> // WriterI
#include <inttypes.h> // PRIx*
#if BX_PLATFORM_ANDROID
# include <android/log.h>
@@ -142,4 +143,32 @@ namespace bx
#undef HEX_DUMP_FORMAT
}
class DebugWriter : public WriterI
{
virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
{
BX_UNUSED(_err);
int32_t total = 0;
char temp[4096];
while (total != _size)
{
uint32_t len = bx::uint32_min(sizeof(temp)-1, _size-total);
memCopy(temp, _data, len);
temp[len] = '\0';
debugOutput(temp);
total += len;
}
return total;
}
};
WriterI* getDebugOut()
{
static DebugWriter s_debugOut;
return &s_debugOut;
}
} // namespace bx