Skip to content
Josephus edited this page Oct 16, 2017 · 7 revisions

Welcome to use The CTWLogger class in your source code.

the file TWLogger.h and TWLogger.cpp is the core implement of logger.
you could Add above two files and TWSmartPointer.h to your project, and then use it to logger what you want to log.

Usage:

The common log interface:

  • WRITE_INFO_LOG/PARAM
  • WRITE_DEBUG_LOG/PARAM
  • WRITE_WARN_LOG/PARAM
  • WRITE_ERROR_LOG/PARAM

WRITE_LOG only convey a string to record while WRITE_PARAM can convey params just like printf in C syntax INFOR/DEBUG/WARN/ERROR indicates the error level which represents prefix mark in every record item in log file.

The lifttime of function record interface:

  • LOG_FUNCTION()
  • TRACE_FUNCTION(pValue)

the two above macro can record the Enter and Leave event about the specific functions, moreover, the TRACE_FUNCTION supports record returned value which type must be int-pointer or DWORD-pointer.

Other useful interfaces:

  • WRITE_TRACE_PARAM records extern information contains code source file name and sentence line
  • LOG_ASSERT perform ASSER() function and record the assert-expression too !

The record file:

  • the log record will store in a folder named "LogFiles" at locate place where your executive program locates default useless you invoke SetFileWriteMode function before invoke WRITE* interfaces.
  • Every log file would store in locate disk formatted as 'YYYY-MM-dd.log'

the macro definition TWINKLE_LOGGER_VERSION in TWLogger.h defines two usaged format for the logger.

if no define TWINKLE_LOGGER_VERSION or define TWINKLE_LOGGER_VERSION as 1, it means:

Only one logger instance can exist in executive program.

if define TWINKLE_LOGGER_VERSION as 2, you can:

you can create more than one logger instance with different 'logger name' through invoking GetLoggerFactory()->GetLoggerProduct(#logger-name#) interface which would store 'logger-name' folder separately.

More detail please read and execute the LoggerTest.cpp as a usage demo...