Repository navigation
Expand file tree
/
Copy pathMacros.cpp
More file actions
58 lines (55 loc) · 1.74 KB
/
Copy pathMacros.cpp
File metadata and controls
58 lines (55 loc) · 1.74 KB
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
/*
This file is part of the Util library.
Copyright (C) 2007-2012 Benjamin Eikel <benjamin@eikel.org>
Copyright (C) 2007-2012 Claudius Jähn <claudius@uni-paderborn.de>
Copyright (C) 2007-2012 Ralf Petring <ralf@petring.net>
This library is subject to the terms of the Mozilla Public License, v. 2.0.
You should have received a copy of the MPL along with this library; see the
file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "Macros.h"
#include <iostream>
#include <sstream>
#if defined(ANDROID)
#include <android/log.h>
#endif /* defined(ANDROID) */
#include <rang.hpp>
namespace Util {
void output(output_priority_t priority, const std::string & message) {
#if defined(ANDROID)
int androidPriority = ANDROID_LOG_UNKNOWN;
switch(priority) {
case OUTPUT_DEBUG:
androidPriority = ANDROID_LOG_DEBUG;
break;
case OUTPUT_WARNING:
androidPriority = ANDROID_LOG_WARN;
break;
case OUTPUT_ERROR:
androidPriority = ANDROID_LOG_ERROR;
break;
}
__android_log_print(androidPriority, "UtilMobile", "%s", message.c_str());
#else
switch(priority) {
case OUTPUT_DEBUG:
std::cerr << rang::style::italic << "Debug" << rang::style::reset << rang::style::reset << ": ";
break;
case OUTPUT_WARNING:
std::cerr << rang::fgB::yellow << "Warning" << rang::style::reset << rang::style::reset << ": ";
break;
case OUTPUT_ERROR:
std::cerr << rang::fgB::red << "Error" << rang::style::reset << rang::style::reset << ": ";
break;
default:
WARN("unexpected case in switch statement");
}
std::cerr << message <<std::endl;
#endif
}
std::string composeDebugMessage(const std::string & message,const char * file,int line){
std::ostringstream s;
s << message << " ("<<file<<":"<<line<<")";
return s.str();
}
}