Welcome to mirror list, hosted at ThFree Co, Russian Federation.

logging.cpp « core « mapswithme « com « jni « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bcda11d2301803533d3f4e0725ed5e7e24ad57b3 (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
82
83
84
85
86
87
#include "logging.hpp"

#include "base/exception.hpp"
#include "base/logging.hpp"

#include "coding/file_writer.hpp"

#include "platform/file_logging.hpp"
#include "platform/platform.hpp"

#include <android/log.h>
#include <cassert>
#include <cstdlib>


namespace jni
{

using namespace my;

void AndroidMessage(LogLevel level, SrcPoint const & src, string const & s)
{
  android_LogPriority pr = ANDROID_LOG_SILENT;

  switch (level)
  {
  case LINFO: pr = ANDROID_LOG_INFO; break;
  case LDEBUG: pr = ANDROID_LOG_DEBUG; break;
  case LWARNING: pr = ANDROID_LOG_WARN; break;
  case LERROR: pr = ANDROID_LOG_ERROR; break;
  case LCRITICAL: pr = ANDROID_LOG_FATAL; break;
  }

  string const out = DebugPrint(src) + " " + s;
  __android_log_write(pr, "MapsWithMe_JNI", out.c_str());
}

void AndroidLogMessage(LogLevel level, SrcPoint const & src, string const & s)
{
  AndroidMessage(level, src, s);
  CHECK(level < g_LogAbortLevel, ("Abort. Log level is too serious", level));
}

void AndroidAssertMessage(SrcPoint const & src, string const & s)
{
#ifdef MWM_LOG_TO_FILE
  LogMessageFile(LCRITICAL, src, s);
#else
  AndroidMessage(LCRITICAL, src, s);
#endif

#ifdef DEBUG
  assert(false);
#else
  std::abort();
#endif
}

void InitSystemLog()
{
#ifdef MWM_LOG_TO_FILE
  SetLogMessageFn(&LogMessageFile);
#else
  SetLogMessageFn(&AndroidLogMessage);
#endif
}

void InitAssertLog()
{
  SetAssertFunction(&AndroidAssertMessage);
}

}

extern "C" {

void DbgPrintC(char const * format, ...)
{
  va_list argptr;
  va_start(argptr, format);

  __android_log_vprint(ANDROID_LOG_INFO, "MapsWithMe_Debug", format, argptr);

  va_end(argptr);
}

}