-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #834 from iguessthislldo/igtd/android
Use Logcat on Android
- Loading branch information
Showing
7 changed files
with
181 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "ace/config-all.h" | ||
|
||
#ifdef ACE_ANDROID | ||
|
||
#include <android/log.h> // Android Logging Functions | ||
|
||
#include "ace/ACE.h" | ||
#include "ace/Log_Category.h" | ||
#include "ace/Log_Msg_Android_Logcat.h" | ||
#include "ace/Log_Record.h" | ||
#include "ace/OS_NS_string.h" | ||
|
||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL | ||
|
||
/** | ||
* Convert ACE Log Priority to Android Logcat Priority | ||
*/ | ||
static android_LogPriority | ||
convert_log_priority (ACE_Log_Priority lm_priority) | ||
{ | ||
switch (lm_priority) { | ||
case LM_TRACE: | ||
case LM_DEBUG: | ||
return ANDROID_LOG_DEBUG; | ||
case LM_STARTUP: | ||
case LM_SHUTDOWN: | ||
case LM_INFO: | ||
case LM_NOTICE: | ||
return ANDROID_LOG_INFO; | ||
case LM_WARNING: | ||
return ANDROID_LOG_WARN; | ||
case LM_CRITICAL: | ||
case LM_ALERT: | ||
case LM_EMERGENCY: | ||
return ANDROID_LOG_FATAL; | ||
case LM_ERROR: | ||
default: | ||
return ANDROID_LOG_ERROR; | ||
} | ||
} | ||
|
||
ACE_Log_Msg_Android_Logcat::ACE_Log_Msg_Android_Logcat () | ||
{ | ||
} | ||
|
||
ACE_Log_Msg_Android_Logcat::~ACE_Log_Msg_Android_Logcat (void) | ||
{ | ||
this->close (); | ||
} | ||
|
||
int | ||
ACE_Log_Msg_Android_Logcat::open (const ACE_TCHAR * logger_key) | ||
{ | ||
return 0; | ||
} | ||
|
||
int | ||
ACE_Log_Msg_Android_Logcat::reset (void) | ||
{ | ||
return close (); | ||
} | ||
|
||
int | ||
ACE_Log_Msg_Android_Logcat::close (void) | ||
{ | ||
return 0; | ||
} | ||
|
||
ssize_t | ||
ACE_Log_Msg_Android_Logcat::log (ACE_Log_Record &log_record) | ||
{ | ||
__android_log_write ( | ||
convert_log_priority (static_cast<ACE_Log_Priority> (log_record.type ())), | ||
"ACE", | ||
log_record.msg_data ()); | ||
return 0; | ||
} | ||
|
||
ACE_END_VERSIONED_NAMESPACE_DECL | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @file Log_Msg_Android_Logcat.h | ||
* | ||
* @author Frederick Hornsey <[email protected]> | ||
*/ | ||
|
||
#ifndef ACE_LOG_MSG_ANDROID_LOGCAT_H | ||
#define ACE_LOG_MSG_ANDROID_LOGCAT_H | ||
|
||
#include /**/ "ace/pre.h" | ||
|
||
#include /**/ "ace/config-all.h" | ||
|
||
#if !defined (ACE_LACKS_PRAGMA_ONCE) | ||
# pragma once | ||
#endif /* ACE_LACKS_PRAGMA_ONCE */ | ||
|
||
#ifdef ACE_ANDROID | ||
|
||
#include "ace/Log_Msg_Backend.h" | ||
#include "ace/Basic_Types.h" | ||
|
||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL | ||
|
||
/** | ||
* @class ACE_Log_Msg_Android_Logcat | ||
* | ||
* @brief Implements an ACE_Log_Msg_Backend that logs messages to Android's | ||
* logging system, called Logcat. On Android this is the default output for ACE | ||
* and the only convenient way of logging. | ||
* | ||
* Reference to the Logging part of Android's NDK API can be found here: | ||
* https://developer.android.com/ndk/reference/group/logging | ||
*/ | ||
class ACE_Export ACE_Log_Msg_Android_Logcat : public ACE_Log_Msg_Backend | ||
{ | ||
public: | ||
ACE_Log_Msg_Android_Logcat (); | ||
virtual ~ACE_Log_Msg_Android_Logcat (); | ||
|
||
/// Initialize the event logging facility. NOP in this class. | ||
virtual int open (const ACE_TCHAR *); | ||
|
||
/// Reset the backend. NOP in this class. | ||
virtual int reset (); | ||
|
||
/// Close the backend completely. NOP in this class. | ||
virtual int close (); | ||
|
||
/// This is called when we want to log a message. | ||
virtual ssize_t log (ACE_Log_Record &log_record); | ||
}; | ||
|
||
ACE_END_VERSIONED_NAMESPACE_DECL | ||
|
||
#endif | ||
|
||
#include /**/ "ace/post.h" | ||
#endif /* ACE_LOG_MSG_ANDROID_LOGCAT */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters