Commit 87b07372 authored by Robert Menzel's avatar Robert Menzel

added logging for Android SDK in eclipse

parent b09e0f70
......@@ -41,6 +41,11 @@
#include <fstream>
#include <sstream>
#ifdef __ANDROID__
#include <android/log.h>
#endif
namespace ACGL{
namespace Utils{
......@@ -57,7 +62,6 @@ public:
~CoutLikeStreamBuffer();
void setPrefix( const std::string &_prefix );
private:
//virtual std::streamsize xsputn(const base_type::char_type* s, std::streamsize n)
......@@ -77,6 +81,12 @@ private:
size_t mBufferMaxSize; // size of the buffer
bool mNewLineIsAboutToStart;
#ifdef __ANDROID__
android_LogPriority mAndroidPriority;
public:
void setAndroidPriority( android_LogPriority _priority ) { mAndroidPriority = _priority; }
#endif
};
/*
......@@ -106,6 +116,15 @@ public:
mStreamBuffer->setPrefix( streamName.str() );
}
}
#ifdef __ANDROID__
switch (DEBUG_LEVEL) {
case 0: mStreamBuffer->setAndroidPriority( ANDROID_LOG_DEBUG); break;
case 1: mStreamBuffer->setAndroidPriority( ANDROID_LOG_INFO); break;
case 2: mStreamBuffer->setAndroidPriority( ANDROID_LOG_WARN); break;
case 3: mStreamBuffer->setAndroidPriority( ANDROID_LOG_ERROR); break;
default: mStreamBuffer->setAndroidPriority( ANDROID_LOG_UNKNOWN);
}
#endif
unmute();
}
......
......@@ -8,7 +8,6 @@
#include <cstdio>
#include <iostream>
using namespace ACGL::Utils;
CoutLikeStreamBuffer::CoutLikeStreamBuffer() : base_type() {
......@@ -35,12 +34,18 @@ CoutLikeStreamBuffer::base_type::int_type CoutLikeStreamBuffer::overflow(base_ty
if ((mBufferSize >= mBufferMaxSize) || ( base_type::traits_type::eq_int_type(ch, base_type::traits_type::eof()))) {
if (mNewLineIsAboutToStart) {
#ifndef __ANDROID__
std::cout << mPrefix;
#endif
mNewLineIsAboutToStart = false;
}
if (mBufferSize > 0) {
mBuffer[mBufferSize] = (char) 0;
#ifdef __ANDROID__
__android_log_print( mAndroidPriority, mPrefix.c_str(), "%s", mBuffer );
#else
std::cout << mBuffer;
#endif
mBufferSize = 0;
}
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment