44 #include <android/log.h>
52 time_t time = std::time(
nullptr);
55 ts = *localtime(&time);
56 strftime(time_buf,
sizeof(time_buf),
"%a %Y-%m-%d %H:%M:%S %Z", &ts);
58 return std::string(time_buf);
68 logStream.push_back(std::string(s));
74 if (logStream.size()>0){
75 #if defined(ANDROID) || defined(WINDOWS)
76 put(
"Destructor called on non-empty log, contents:\n\n");
78 put(
"\033[1;33m[WARN] \033[0mDestructor called on non-empty log, contents:\n\n");
84 __android_log_print(ANDROID_LOG_WARN,
"",
"%s",
get().c_str());
90 void androidLog(){
if(logStream.size()>0){__android_log_print(ANDROID_LOG_INFO,
"Hop",
"%s",
get().c_str());} }
93 void put(std::string s){
95 logStream.push_back(s);
98 inline void put(
const char * c){
99 std::string s =
get_time() +
" " + std::string(c);
100 logStream.push_back(s);
103 inline std::string
get() {
105 for (
unsigned i = 0; i < logStream.size(); i++){
106 l += logStream[i] +
"\n";
112 inline size_t size(){
return logStream.size();}
115 std::vector<std::string> logStream;
129 virtual std::string
get()
const {
return std::string(
"");};
144 #if !defined(ANDROID) && !defined(WINDOWS)
145 const char * u =
"\033[1;36m[INFO] \033[0m";
147 const char * u =
"[INFO] ";
160 #if !defined(ANDROID) && !defined(WINDOWS)
161 const char * u =
"\033[1;33m[WARN] \033[0m";
163 const char * u =
"[WARN] ";
180 return s+std::string(
"UNSPECIFIED");
183 return s+std::string(
"LUA");
186 return s+std::string(
"UNSPECIFIED");
196 std::string
get()
const{
return u+std::string(
"\033[1;33m(")+x+std::string(
")\033[0m ")+
msg;}
198 const char * u =
"\033[1;31m[ERR] \033[0m";
211 std::vector<std::string> s = std::vector<std::string>{
"\\",
"-",
"/",
"-"}
213 : length(l), progress(p), sequence(s)
218 if (progress < length){
220 o <<
'\t' << sequence[progress % sequence.size()];
230 std::vector<std::string> sequence;
ERR(const char *c)
Definition jLog.h:193
std::string get() const
Definition jLog.h:196
ERR(std::string s)
Definition jLog.h:192
ERR(ERRORCODE xx, std::string s)
Definition jLog.h:194
ERR(ERRORCODE xx, const char *c)
Definition jLog.h:195
std::string get() const
Definition jLog.h:142
LogType(std::string s)
Definition jLog.h:127
std::string msg
Definition jLog.h:132
void operator>>(Log &l)
Definition jLog.h:130
LogType()
Definition jLog.h:126
LogType(const char *c)
Definition jLog.h:128
virtual std::string get() const
Definition jLog.h:129
void put(const char *c)
Definition jLog.h:98
void put(std::string s)
Definition jLog.h:93
Log(const char *s)
Definition jLog.h:66
size_t size()
Definition jLog.h:112
Log()
Definition jLog.h:71
~Log()
Definition jLog.h:73
std::string get()
Definition jLog.h:103
bool next(std::ostream &o)
Definition jLog.h:215
Progress(uint64_t l, uint64_t p, std::vector< std::string > s=std::vector< std::string >{"\\","-","/","-"})
Definition jLog.h:208
std::string get() const
Definition jLog.h:158
std::ostream & operator<<(std::ostream &o, Log &l)
Definition jLog.h:118
std::string get_time()
Definition jLog.h:50
std::string operator+(std::string s, const ERRORCODE e)
Definition jLog.h:175
ERRORCODE
Definition jLog.h:173
@ UNSPECIFIED
Definition jLog.h:173
@ LUA_ERROR
Definition jLog.h:173