7 #include <android/log.h>
24 __android_log_print(ANDROID_LOG_INFO,
"Cytopia",
"%s", message.c_str());
26 std::cout << message << std::endl;
43 std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
45 std::strftime(buf,
sizeof(buf),
"%b %d %H:%M:%S", std::localtime(&now));
55 std::fstream fs(errfname, std::fstream::out | std::fstream::app);
60 fs << errorMessage << std::endl;
63 fs.seekp(0, std::fstream::end);
64 std::streampos Size = fs.tellp();
65 if (Size > MAX_LOG_SIZE_BYTES::value)
68 std::fstream fsToRotate(errfname, std::fstream::in | std::fstream::out);
71 std::streampos Cut = 0;
72 while (Size - Cut > MAX_LOG_SIZE_BYTES::value / 2 && std::getline(fsToRotate, line))
73 Cut += line.size() + 1;
74 stringstream truncatedstream;
75 truncatedstream << fsToRotate.rdbuf();
77 fsToRotate.open(
fs::getBasePath() +
string{
"error.log"}, std::fstream::trunc | std::fstream::out);
78 fsToRotate << truncatedstream.str();