Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTLog Class Reference

#include <OTLog.hpp>

Static Public Member Functions

static EXPORT bool Init (const OTString &strThreadContext="", const int32_t &nLogLevel=0)
 
static EXPORT bool IsInitialized ()
 
static EXPORT bool Cleanup ()
 
static EXPORT const char * Version ()
 
static EXPORT const OTStringGetVersion ()
 
static EXPORT const char * PathSeparator ()
 
static EXPORT const OTStringGetPathSeparator ()
 
static EXPORT const OTStringGetThreadContext ()
 
static EXPORT const char * LogFilePath ()
 
static EXPORT const OTStringGetLogFilePath ()
 
static EXPORT int32_t LogLevel ()
 
static EXPORT bool SetLogLevel (const int32_t &nLogLevel)
 
static EXPORT bool LogToFile (const OTString &strOutput)
 
static EXPORT int32_t GetMemlogSize ()
 
static EXPORT OTString GetMemlogAtIndex (int32_t nIndex)
 
static EXPORT OTString PeekMemlogFront ()
 
static EXPORT OTString PeekMemlogBack ()
 
static EXPORT bool PopMemlogFront ()
 
static EXPORT bool PopMemlogBack ()
 
static EXPORT bool PushMemlogFront (const OTString &strLog)
 
static EXPORT bool PushMemlogBack (const OTString &strLog)
 
static EXPORT bool SleepSeconds (int64_t lSeconds)
 
static EXPORT bool SleepMilliseconds (int64_t lMilliseconds)
 
static EXPORT void Output (int32_t nVerbosity, const char *szOutput)
 
static EXPORT void vOutput (int32_t nVerbosity, const char *szOutput,...)
 
static EXPORT void Error (const char *szError)
 
static EXPORT void vError (const char *szError,...)
 
static EXPORT void Errno (const char *szLocation=nullptr)
 
static EXPORT bool StringFill (OTString &out_strString, const char *szString, int32_t iLength, const char *szAppend=nullptr)
 
static EXPORT void SetupSignalHandler ()
 

Detailed Description

Definition at line 196 of file OTLog.hpp.

Member Function Documentation

bool opentxs::OTLog::Cleanup ( )
static

Definition at line 377 of file OTLog.cpp.

378 {
379  if (nullptr != pLogger) {
380  delete pLogger;
381  pLogger = nullptr;
382  return true;
383  }
384  return false;
385 }
void opentxs::OTLog::Errno ( const char *  szLocation = nullptr)
static

defined(_GNU_SOURCE))

Definition at line 859 of file OTLog.cpp.

860 {
861  bool bHaveLogger(false);
862  if (nullptr != pLogger)
863  if (pLogger->IsInitialized()) bHaveLogger = true;
864 
865  // lets check if we are Initialized in this context
866  if (bHaveLogger) CheckLogger(OTLog::pLogger);
867 
868  const int32_t errnum = errno;
869  char buf[128];
870  buf[0] = '\0';
871 
872  int32_t nstrerr = 0;
873  char* szErrString = nullptr;
874 
875 //#if((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) &&
877 
878 #if defined(_GNU_SOURCE) && defined(__linux__) && !defined(ANDROID)
879  szErrString = strerror_r(errnum, buf, 127);
880 #elif(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
881  nstrerr = strerror_r(errnum, buf,
882  127); // (strerror_r is threadsafe version of strerror)
883 #endif
884 
885  const char* szFunc = "OTLog::Errno";
886  const char* sz_location = (nullptr == szLocation) ? "" : szLocation;
887 
888  if (nullptr == szErrString) szErrString = buf;
889 
890  if (0 == nstrerr)
891  otErr << szFunc << " " << sz_location << ": errno " << errnum << ": "
892  << (szErrString[0] != '\0' ? szErrString : "") << ".\n";
893  else
894  otErr << szFunc << " " << sz_location << ": errno: " << errnum
895  << ". (Unable to retrieve error string for that number.)\n";
896 }
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
OTLOG_IMPORT OTLogStream otErr
void opentxs::OTLog::Error ( const char *  szError)
static

Definition at line 831 of file OTLog.cpp.

832 {
833  bool bHaveLogger(false);
834  if (nullptr != pLogger)
835  if (pLogger->IsInitialized()) bHaveLogger = true;
836 
837  // lets check if we are Initialized in this context
838  if (bHaveLogger) CheckLogger(OTLog::pLogger);
839 
840  if ((nullptr == szError)) return;
841 
842  // We store the last 1024 logs so programmers can access them via the API.
843  if (bHaveLogger) OTLog::PushMemlogFront(szError);
844 
845 #ifndef ANDROID // if NOT android
846 
847  LogToFile(szError);
848 
849 #else // if Android
850  __android_log_write(ANDROID_LOG_ERROR, "OT Error", szError);
851 #endif
852 }
static EXPORT bool LogToFile(const OTString &strOutput)
Definition: OTLog.cpp:462
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
static EXPORT bool PushMemlogFront(const OTString &strLog)
Definition: OTLog.cpp:609
const OTString & opentxs::OTLog::GetLogFilePath ( )
static

Definition at line 428 of file OTLog.cpp.

429 {
430  return pLogger->m_strLogFilePath;
431 }
OTString opentxs::OTLog::GetMemlogAtIndex ( int32_t  nIndex)
static

Definition at line 499 of file OTLog.cpp.

500 {
501  // lets check if we are Initialized in this context
502  CheckLogger(OTLog::pLogger);
503 
504  uint32_t uIndex = static_cast<uint32_t>(nIndex);
505 
506  if ((nIndex < 0) || (uIndex >= OTLog::pLogger->logDeque.size())) {
507  otErr << __FUNCTION__ << ": index out of bounds: " << nIndex << "\n";
508  return "";
509  }
510 
511  if (nullptr != OTLog::pLogger->logDeque.at(uIndex))
512  ; // check for null
513  else
514  OT_FAIL;
515 
516  const OTString strLogEntry = *OTLog::pLogger->logDeque.at(uIndex);
517 
518  if (strLogEntry.Exists())
519  return strLogEntry;
520  else
521  return "";
522 }
#define OT_FAIL
Definition: Assert.hpp:139
OTLOG_IMPORT OTLogStream otErr
int32_t opentxs::OTLog::GetMemlogSize ( )
static

Definition at line 526 of file OTLog.cpp.

527 {
528  // lets check if we are Initialized in this context
529  CheckLogger(OTLog::pLogger);
530 
531  return static_cast<int32_t>(OTLog::pLogger->logDeque.size());
532 }
const OTString & opentxs::OTLog::GetPathSeparator ( )
static

Definition at line 412 of file OTLog.cpp.

413 {
414  return m_strPathSeparator;
415 }
const OTString & opentxs::OTLog::GetThreadContext ( )
static

Definition at line 419 of file OTLog.cpp.

420 {
421  return pLogger->m_strThreadContext;
422 }
const OTString & opentxs::OTLog::GetVersion ( )
static

Definition at line 403 of file OTLog.cpp.

404 {
405  return m_strVersion;
406 }
bool opentxs::OTLog::Init ( const OTString strThreadContext = "",
const int32_t &  nLogLevel = 0 
)
static

Definition at line 300 of file OTLog.cpp.

301 {
302  if (nullptr == pLogger) {
303  pLogger = new OTLog();
304  pLogger->m_bInitialized = false;
305  }
306 
307  if (strThreadContext.Compare(GLOBAL_LOGNAME)) return false;
308 
309  if (!pLogger->m_bInitialized) {
310  pLogger->logDeque = std::deque<OTString*>();
311  pLogger->m_strThreadContext = strThreadContext;
312 
313  pLogger->m_nLogLevel = nLogLevel;
314 
315  if (!strThreadContext.Exists() ||
316  strThreadContext.Compare("")) // global
317  {
318  pLogger->m_strLogFileName = GLOBAL_LOGFILE;
319  }
320  else // not global
321  {
322 
323  pLogger->m_strLogFileName.Format(
324  "%s%s%s", LOGFILE_PRE, strThreadContext.Get(), LOGFILE_EXT);
325 
326  OTSettings config(OTPaths::GlobalConfigFile());
327 
328  config.Reset();
329  if (!config.Load()) {
330  return false;
331  };
332 
333  bool bIsNew(false);
334  if (!config.CheckSet_str("logfile", strThreadContext,
335  pLogger->m_strLogFileName,
336  pLogger->m_strLogFileName, bIsNew)) {
337  return false;
338  }
339 
340  if (!config.Save()) {
341  return false;
342  };
343  config.Reset();
344  }
345 
346 #ifdef ANDROID
347  if (OTPaths::HomeFolder().Exists())
348 #endif
349  if (!OTPaths::AppendFile(pLogger->m_strLogFilePath,
351  pLogger->m_strLogFileName)) {
352  return false;
353  };
354 
355  pLogger->m_bInitialized = true;
356 
357  // Set the new log-assert function pointer.
358  Assert* pLogAssert = new Assert(OTLog::logAssert);
359  std::swap(pLogAssert, Assert::s_pAssert);
360  delete pLogAssert;
361  pLogAssert = nullptr;
362 
363  return true;
364  }
365  else {
366  return false;
367  }
368 }
#define LOGFILE_PRE
Definition: OTLog.cpp:241
#define LOGFILE_EXT
Definition: OTLog.cpp:242
#define GLOBAL_LOGFILE
Definition: OTLog.cpp:244
static Assert * s_pAssert
Definition: Assert.hpp:173
static EXPORT const OTString & AppDataFolder()
Definition: OTPaths.cpp:254
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
#define GLOBAL_LOGNAME
Definition: OTLog.cpp:243
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
static EXPORT bool AppendFile(OTString &out_strPath, const OTString &strBasePath, const OTString &strFileName)
Definition: OTPaths.cpp:1245
static EXPORT const OTString & HomeFolder()
Definition: OTPaths.cpp:240
static EXPORT const OTString & GlobalConfigFile()
Definition: OTPaths.cpp:286
bool opentxs::OTLog::IsInitialized ( )
static

Definition at line 371 of file OTLog.cpp.

372 {
373  return nullptr != pLogger && pLogger->m_bInitialized;
374 }
const char * opentxs::OTLog::LogFilePath ( )
static

Definition at line 424 of file OTLog.cpp.

425 {
426  return OTLog::GetLogFilePath().Get();
427 }
EXPORT const char * Get() const
Definition: OTString.cpp:1045
static EXPORT const OTString & GetLogFilePath()
Definition: OTLog.cpp:428
int32_t opentxs::OTLog::LogLevel ( )
static

Definition at line 434 of file OTLog.cpp.

435 {
436  if (nullptr != pLogger)
437  return pLogger->m_nLogLevel;
438  else
439  return 0;
440 }
bool opentxs::OTLog::LogToFile ( const OTString strOutput)
static

Definition at line 462 of file OTLog.cpp.

463 {
464  // We now do this either way.
465  {
466  std::cerr << strOutput;
467  std::cerr.flush();
468  }
469 
470  // now log to file, if we can.
471 
472  bool bHaveLogger(false);
473  if (nullptr != pLogger)
474  if (pLogger->IsInitialized()) bHaveLogger = true;
475 
476  // lets check if we are Initialized in this context
477  if (bHaveLogger) CheckLogger(OTLog::pLogger);
478 
479  bool bSuccess = false;
480 
481  if (bHaveLogger) {
482  // Append to logfile
483  if ((strOutput.Exists()) &&
484  (OTLog::pLogger->m_strLogFilePath.Exists())) {
485  std::ofstream logfile;
486  logfile.open(OTLog::LogFilePath(), std::ios::app);
487 
488  if (!logfile.fail()) {
489  logfile << strOutput;
490  logfile.close();
491  bSuccess = true;
492  }
493  }
494  }
495 
496  return bSuccess;
497 }
EXPORT bool Exists() const
Definition: OTString.cpp:1035
static EXPORT const char * LogFilePath()
Definition: OTLog.cpp:424
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
void opentxs::OTLog::Output ( int32_t  nVerbosity,
const char *  szOutput 
)
static

Definition at line 710 of file OTLog.cpp.

711 {
712  bool bHaveLogger(false);
713  if (nullptr != pLogger)
714  if (pLogger->IsInitialized()) bHaveLogger = true;
715 
716  // lets check if we are Initialized in this context
717  if (bHaveLogger) CheckLogger(OTLog::pLogger);
718 
719  // If log level is 0, and verbosity of this message is 2, don't bother
720  // logging it.
721  // if (nVerbosity > OTLog::__CurrentLogLevel || (nullptr == szOutput))
722  if ((nVerbosity > LogLevel()) || (nullptr == szOutput) ||
723  (LogLevel() == (-1)))
724  return;
725 
726  // We store the last 1024 logs so programmers can access them via the API.
727  if (bHaveLogger) OTLog::PushMemlogFront(szOutput);
728 
729 #ifndef ANDROID // if NOT android
730 
731  LogToFile(szOutput);
732 
733 #else // if IS Android
734  /*
735  typedef enum android_LogPriority {
736  ANDROID_LOG_UNKNOWN = 0,
737  ANDROID_LOG_DEFAULT, // only for SetMinPriority()
738  ANDROID_LOG_VERBOSE,
739  ANDROID_LOG_DEBUG,
740  ANDROID_LOG_INFO,
741  ANDROID_LOG_WARN,
742  ANDROID_LOG_ERROR,
743  ANDROID_LOG_FATAL,
744  ANDROID_LOG_SILENT, // only for SetMinPriority(); must be last
745  } android_LogPriority;
746  */
747  switch (nVerbosity) {
748  case 0:
749  case 1:
750  __android_log_write(ANDROID_LOG_INFO, "OT Output", szOutput);
751  break;
752  case 2:
753  case 3:
754  __android_log_write(ANDROID_LOG_DEBUG, "OT Debug", szOutput);
755  break;
756  case 4:
757  case 5:
758  __android_log_write(ANDROID_LOG_VERBOSE, "OT Verbose", szOutput);
759  break;
760  default:
761  __android_log_write(ANDROID_LOG_UNKNOWN, "OT Unknown", szOutput);
762  break;
763  }
764 #endif
765 }
static EXPORT bool LogToFile(const OTString &strOutput)
Definition: OTLog.cpp:462
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
static EXPORT int32_t LogLevel()
Definition: OTLog.cpp:434
static EXPORT bool PushMemlogFront(const OTString &strLog)
Definition: OTLog.cpp:609
const char * opentxs::OTLog::PathSeparator ( )
static

Definition at line 408 of file OTLog.cpp.

409 {
410  return OTLog::GetPathSeparator().Get();
411 }
EXPORT const char * Get() const
Definition: OTString.cpp:1045
static EXPORT const OTString & GetPathSeparator()
Definition: OTLog.cpp:412
OTString opentxs::OTLog::PeekMemlogBack ( )
static

Definition at line 554 of file OTLog.cpp.

555 {
556  // lets check if we are Initialized in this context
557  CheckLogger(OTLog::pLogger);
558 
559  if (OTLog::pLogger->logDeque.size() <= 0) return nullptr;
560 
561  if (nullptr != OTLog::pLogger->logDeque.back())
562  ; // check for null
563  else
564  OT_FAIL;
565 
566  const OTString strLogEntry = *OTLog::pLogger->logDeque.back();
567 
568  if (strLogEntry.Exists())
569  return strLogEntry;
570  else
571  return "";
572 }
#define OT_FAIL
Definition: Assert.hpp:139
OTString opentxs::OTLog::PeekMemlogFront ( )
static

Definition at line 534 of file OTLog.cpp.

535 {
536  // lets check if we are Initialized in this context
537  CheckLogger(OTLog::pLogger);
538 
539  if (OTLog::pLogger->logDeque.size() <= 0) return nullptr;
540 
541  if (nullptr != OTLog::pLogger->logDeque.front())
542  ; // check for null
543  else
544  OT_FAIL;
545 
546  const OTString strLogEntry = *OTLog::pLogger->logDeque.front();
547 
548  if (strLogEntry.Exists())
549  return strLogEntry;
550  else
551  return "";
552 }
#define OT_FAIL
Definition: Assert.hpp:139
bool opentxs::OTLog::PopMemlogBack ( )
static

Definition at line 592 of file OTLog.cpp.

593 {
594  // lets check if we are Initialized in this context
595  CheckLogger(OTLog::pLogger);
596 
597  if (OTLog::pLogger->logDeque.size() <= 0) return false;
598 
599  OTString* strLogBack = OTLog::pLogger->logDeque.back();
600  if (nullptr != strLogBack) delete strLogBack;
601  strLogBack = nullptr;
602 
603  OTLog::pLogger->logDeque.pop_back();
604 
605  return true;
606 }
bool opentxs::OTLog::PopMemlogFront ( )
static

Definition at line 575 of file OTLog.cpp.

576 {
577  // lets check if we are Initialized in this context
578  CheckLogger(OTLog::pLogger);
579 
580  if (OTLog::pLogger->logDeque.size() <= 0) return false;
581 
582  OTString* strLogFront = OTLog::pLogger->logDeque.front();
583  if (nullptr != strLogFront) delete strLogFront;
584  strLogFront = nullptr;
585 
586  OTLog::pLogger->logDeque.pop_front();
587 
588  return true;
589 }
bool opentxs::OTLog::PushMemlogBack ( const OTString strLog)
static

Definition at line 627 of file OTLog.cpp.

628 {
629  // lets check if we are Initialized in this context
630  CheckLogger(OTLog::pLogger);
631 
632  OT_ASSERT(strLog.Exists());
633 
634  OTLog::pLogger->logDeque.push_back(new OTString(strLog));
635 
636  return true;
637 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
bool opentxs::OTLog::PushMemlogFront ( const OTString strLog)
static

Definition at line 609 of file OTLog.cpp.

610 {
611  // lets check if we are Initialized in this context
612  CheckLogger(OTLog::pLogger);
613 
614  OT_ASSERT(strLog.Exists());
615 
616  OTLog::pLogger->logDeque.push_front(new OTString(strLog));
617 
618  if (OTLog::pLogger->logDeque.size() > LOG_DEQUE_SIZE) {
619  OTLog::PopMemlogBack(); // We start removing from the back when it
620  // reaches this size.
621  }
622 
623  return true;
624 }
static EXPORT bool PopMemlogBack()
Definition: OTLog.cpp:592
#define OT_ASSERT(x)
Definition: Assert.hpp:150
#define LOG_DEQUE_SIZE
Definition: OTLog.cpp:165
bool opentxs::OTLog::SetLogLevel ( const int32_t &  nLogLevel)
static

Definition at line 443 of file OTLog.cpp.

444 {
445  if (nullptr == pLogger) {
446  OT_FAIL;
447  }
448  else {
449  pLogger->m_nLogLevel = nLogLevel;
450  return true;
451  }
452 }
#define OT_FAIL
Definition: Assert.hpp:139
void opentxs::OTLog::SetupSignalHandler ( )
static

Definition at line 1315 of file OTLog.cpp.

1316 {
1317  static int32_t nCount = 0;
1318 
1319  if (0 == nCount) {
1320  ++nCount;
1321 
1322  OT_HANDLE_SIGNAL(SIGINT) // Ctrl-C. (So we can shutdown gracefully, I
1323  // suppose, on Ctrl-C.)
1324  OT_HANDLE_SIGNAL(SIGSEGV) // Segmentation fault.
1325  // OT_HANDLE_SIGNAL(SIGABRT) // Abort.
1326  OT_HANDLE_SIGNAL(SIGBUS) // Bus error
1327  // OT_HANDLE_SIGNAL(SIGHUP) // I believe this is for sending a
1328  // "restart" signal to your process, that sort of thing.
1329  OT_HANDLE_SIGNAL(SIGTERM) // Used by kill pid (NOT kill -9 pid). Used
1330  // for "killing softly."
1331  OT_HANDLE_SIGNAL(SIGILL) // Illegal instruction.
1332  OT_HANDLE_SIGNAL(SIGTTIN) // SIGTTIN may be sent to a background process
1333  // that attempts to read from its controlling
1334  // terminal.
1335  OT_HANDLE_SIGNAL(SIGTTOU) // SIGTTOU may be sent to a background process
1336  // that attempts to write to its controlling
1337  // terminal.
1338  // OT_HANDLE_SIGNAL(SIGPIPE) // Unix supports the principle of
1339  // piping. When a pipe is broken, the process writing to it is sent the
1340  // SIGPIPE.
1341  // OT_HANDLE_SIGNAL(SIGKILL) // kill -9. "The receiving process
1342  // cannot perform any clean-up upon receiving this signal."
1343  OT_HANDLE_SIGNAL(SIGFPE) // Floating point exception.
1344  OT_HANDLE_SIGNAL(SIGXFSZ) // SIGXFSZ is the signal sent to a process
1345  // when it grows a file larger than the
1346  // maximum allowed size.
1347  // OT_HANDLE_SIGNAL(SIGQUIT) // SIGQUIT is the signal sent to a
1348  // process by its controlling terminal when the user requests that the
1349  // process perform a core dump.
1350  OT_HANDLE_SIGNAL(SIGSYS) // sent when a process supplies an incorrect
1351  // argument to a system call.
1352  // OT_HANDLE_SIGNAL(SIGTRAP) // used by debuggers
1353  }
1354 }
#define OT_HANDLE_SIGNAL(OT_SIGNAL_TYPE)
Definition: OTLog.cpp:1294
bool opentxs::OTLog::SleepMilliseconds ( int64_t  lMilliseconds)
static

Definition at line 651 of file OTLog.cpp.

652 {
653 #ifdef _WIN32
654  Sleep(static_cast<DWORD>(lMilliseconds));
655 #else
656  usleep(lMilliseconds * 1000);
657 #endif
658  return true;
659 }
bool opentxs::OTLog::SleepSeconds ( int64_t  lSeconds)
static

Definition at line 640 of file OTLog.cpp.

641 {
642 #ifdef _WIN32
643  Sleep(static_cast<DWORD>(1000 * lSeconds));
644 #else
645  sleep(lSeconds);
646 #endif
647  return true;
648 }
bool opentxs::OTLog::StringFill ( OTString out_strString,
const char *  szString,
int32_t  iLength,
const char *  szAppend = nullptr 
)
static

Definition at line 900 of file OTLog.cpp.

902 {
903  std::string strString(szString);
904 
905  if (nullptr != szAppend) strString.append(szAppend);
906 
907  for (; (static_cast<int32_t>(strString.length()) < iLength);
908  strString.append(" "))
909  ;
910 
911  out_strString.Set(strString.c_str());
912 
913  return true;
914 }
void opentxs::OTLog::vError ( const char *  szError,
  ... 
)
static

Definition at line 800 of file OTLog.cpp.

801 {
802  bool bHaveLogger(false);
803  if (nullptr != pLogger)
804  if (pLogger->IsInitialized()) bHaveLogger = true;
805 
806  // lets check if we are Initialized in this context
807  if (bHaveLogger) CheckLogger(OTLog::pLogger);
808 
809  if ((nullptr == szError)) return;
810 
811  va_list args;
812  va_start(args, szError);
813 
814  std::string strOutput;
815 
816  const bool bFormatted = OTString::vformat(szError, &args, strOutput);
817 
818  va_end(args);
819 
820  if (bFormatted)
821  OTLog::Error(strOutput.c_str());
822  else
823  OT_FAIL;
824 }
static EXPORT void Error(const char *szError)
Definition: OTLog.cpp:831
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
#define OT_FAIL
Definition: Assert.hpp:139
static bool vformat(const char *fmt, std::va_list *pvl, std::string &s)
Definition: OTString.cpp:191
const char * opentxs::OTLog::Version ( )
static

Definition at line 399 of file OTLog.cpp.

400 {
401  return OTLog::GetVersion().Get();
402 }
static EXPORT const OTString & GetVersion()
Definition: OTLog.cpp:403
EXPORT const char * Get() const
Definition: OTString.cpp:1045
void opentxs::OTLog::vOutput ( int32_t  nVerbosity,
const char *  szOutput,
  ... 
)
static

Definition at line 768 of file OTLog.cpp.

769 {
770  bool bHaveLogger(false);
771  if (nullptr != pLogger)
772  if (pLogger->IsInitialized()) bHaveLogger = true;
773 
774  // lets check if we are Initialized in this context
775  if (bHaveLogger) CheckLogger(OTLog::pLogger);
776 
777  // If log level is 0, and verbosity of this message is 2, don't bother
778  // logging it.
779  if (((0 != LogLevel()) && (nVerbosity > LogLevel())) ||
780  (nullptr == szOutput))
781  return;
782 
783  va_list args;
784  va_start(args, szOutput);
785 
786  std::string strOutput;
787 
788  const bool bFormatted = OTString::vformat(szOutput, &args, strOutput);
789 
790  va_end(args);
791 
792  if (bFormatted)
793  OTLog::Output(nVerbosity, strOutput.c_str());
794  else
795  OT_FAIL;
796  return;
797 }
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
Definition: OTLog.cpp:710
static EXPORT bool IsInitialized()
Definition: OTLog.cpp:371
#define OT_FAIL
Definition: Assert.hpp:139
static EXPORT int32_t LogLevel()
Definition: OTLog.cpp:434
static bool vformat(const char *fmt, std::va_list *pvl, std::string &s)
Definition: OTString.cpp:191

The documentation for this class was generated from the following files: