Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
acgl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACGL
acgl
Commits
87b07372
Commit
87b07372
authored
Jan 06, 2013
by
Robert Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added logging for Android SDK in eclipse
parent
b09e0f70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
include/ACGL/Utils/Log.hh
include/ACGL/Utils/Log.hh
+20
-1
src/ACGL/Utils/Log.cc
src/ACGL/Utils/Log.cc
+6
-1
No files found.
include/ACGL/Utils/Log.hh
View file @
87b07372
...
...
@@ -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
();
}
...
...
src/ACGL/Utils/Log.cc
View file @
87b07372
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment