1 #ifndef LOGGER_HPP 2 #define LOGGER_HPP 3 4 /* 5 * ANDROID_LOGGER -- defined only incase of android ndk build 6 */ 7 8 #include <iostream> 9 #include <string> 10 #include <fstream> 11 #include <xml_writer.h> 12 #include "common.h" 13 14 #ifdef ANDROID_LOGGER 15 #include <jni.h> 16 #endif 17 18 using namespace std; 19 20 class logger 21 { 22 public: 23 bool enableXml; 24 ofstream xmlFile; 25 xmlWriter *xw; 26 27 #ifdef ANDROID_LOGGER 28 JNIEnv *jEnv; 29 jobject *jObj; 30 jmethodID printCallback; 31 #endif 32 33 logger(bool _enableXml=false, string _xmlFileName=""); 34 ~logger(); 35 36 // Overloaded function to print on stdout/android activity 37 void print(string str); 38 void print(double val); 39 void print(float val); 40 void print(int val); 41 void print(unsigned int val); 42 43 // Functions to record metrics into xml file 44 void xmlOpenTag(string tag); 45 void xmlAppendAttribs(string key, string value); 46 void xmlAppendAttribs(string key, uint value); 47 void xmlSetContent(string value); 48 void xmlSetContent(float value); 49 void xmlCloseTag(); 50 51 void xmlRecord(string tag, string value); 52 void xmlRecord(string tag, float value); 53 }; 54 55 #endif // LOGGER_HPP 56