This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.cpp
104 lines (76 loc) · 1.6 KB
/
Log.cpp
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Log.cpp
*
* Created on: 2011-5-14
* Author: simophin
*/
#include "Log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <iostream>
#ifdef ANDROID
#include <android/log.h>
#endif
void Log::logWarning(const char *fmt, ...)
{
va_list va;
va_start(va,fmt);
vLogWarning(fmt,va);
va_end(va);
}
void Log::vLogError(const char *fmt, va_list va)
{
vLog(LOG_ERROR,fmt,va);
}
void Log::vLogDebug(const char *fmt, va_list list)
{
vLog(LOG_DEBUG,fmt,list);
}
void Log::logError(const char *fmt, ...)
{
va_list va;
va_start(va,fmt);
vLogError(fmt,va);
va_end(va);
}
void Log::log(Log::Level level, const char *fmt, ...)
{
va_list va;
va_start(va,fmt);
vLog(level,fmt,va);
va_end(va);
}
void Log::vLogWarning(const char *fmt, va_list list)
{
vLog(LOG_WARNING,fmt,list);
}
void Log::vLog(Level level, const char *fmt, va_list va)
{
const char * levelFmt = 0;
static char buf[1024];
switch(level){
case LOG_WARNING: levelFmt = "WARNING:" ; break;
case LOG_ERROR: levelFmt = "ERROR:" ; break;
default:
case LOG_DEBUG: levelFmt = "DEBUG:"; break;
}
vsnprintf (buf, sizeof(buf), fmt, va);
buf[sizeof(buf)-1] = '\0';
#ifndef ANDROID
std::cerr << levelFmt << buf << std::endl;
#else
__android_log_vprint (ANDROID_LOG_DEBUG,"RemoteVision", fmt,va);
#endif
}
void Log::log(Level level, const String &str) {
log(level, str.c_str());
}
void Log::logDebug(const char *fmt, ...)
{
va_list va;
va_start(va,fmt);
vLogDebug(fmt,va);
va_end(va);
}