int cFile::Printf(const char * a_Fmt, ...) { AString buf; va_list args; va_start(args, a_Fmt); AppendVPrintf(buf, a_Fmt, args); va_end(args); return Write(buf.c_str(), buf.length()); }
void cCommandOutputCallback::Out(const char * a_Fmt, ...) { AString Output; va_list args; va_start(args, a_Fmt); AppendVPrintf(Output, a_Fmt, args); va_end(args); Output.append("\n"); Out(Output); }
void cLog::Log(const char * a_Format, va_list argList) { AString Message; AppendVPrintf(Message, a_Format, argList); time_t rawtime; time ( &rawtime ); struct tm* timeinfo; #ifdef _MSC_VER struct tm timeinforeal; timeinfo = &timeinforeal; localtime_s(timeinfo, &rawtime ); #else timeinfo = localtime( &rawtime ); #endif AString Line; #ifdef _DEBUG Printf(Line, "[%04x|%02d:%02d:%02d] %s", cIsThread::GetCurrentID(), timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, Message.c_str()); #else Printf(Line, "[%02d:%02d:%02d] %s", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, Message.c_str()); #endif if (m_File) { fprintf(m_File, "%s\n", Line.c_str()); fflush(m_File); } // Print to console: #if defined(ANDROID_NDK) //__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); #else printf("%s", Line.c_str()); #endif #if defined (_WIN32) && defined(_DEBUG) // In a Windows Debug build, output the log to debug console as well: OutputDebugStringA((Line + "\n").c_str()); #endif // _WIN32 }