summaryrefslogtreecommitdiff
path: root/ACE/ace/Log_Msg_Android_Logcat.cpp
blob: 2985965136ca172d57655181744c2f5d10034f07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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 *)
{
  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