winIDEA SDK
isys::CLogger Class Reference

Description

This class can be used to add logging to all controller classes.

Unlike usual loggers, this class produces runnable Python or Java code. For this reason the log() methods are a bit different - they accept object name and method name as parameters, which are than used when writing code to the log file. The result is program file, which contains only calls to isystem.connect. This is useful, when we would like to quickly reproduce the problem or simply for readable overview of what is going on between our application and target hardware.

However, although the log file is a runnable program, the functionality will usually NOT be the same as that of original program. For example, if the original program calls getStatus() in a loop until condition is met, the log file will contain on the number of getStatus() calls, without loop or condition. The log file is intended as debugging help, not as full substitute of the original program.

NOTE: This class is not intended to be used directly by end users. It is used internally, when the user code makes isystem.connect calls. See ConnectionMgr::initLogger() for initialization of internal logger.


#include <CLogger.h>

Public Types

enum  LogFileLanguage { JAVA , PYTHON }
 Enum type for logging language selection. More...
 

Public Member Functions

 CLogger (const std::string &fileName, LogFileLanguage language)
 Opens log file and initializes it. More...
 
 CLogger (const std::string &fileName, LogFileLanguage language, bool isLogToStdOut, double timeDiffToIgnore, const std::string &header)
 Opens log file and initializes it. More...
 
void closeLog (const std::string &footer)
 Closes log file and turns off the logging. More...
 
void createSType (const std::string &valueName, const SType &sType)
 Creates and fills CValueType object. More...
 
void createVar (const std::string &varName, const std::string &varType)
 Logs declaration and assignment statement, for example SProfilerStartingPoint sp = SProfilerStartingPoint();.
 
void fillVectorBYTE (const std::string &varName, const std::vector< uint8_t > &buff)
 Creates vector of bytes in script language and assigns its values from buff.
 
bool isLoggingOn ()
 Returns if logging is turned on. More...
 
void log (const std::string &code)
 This method may be called from client code to insert user specific script code.
 
void log (const std::string &objName, const std::string &methodName)
 Logs call of method with no parameter. More...
 
void log (const std::string &objName, const std::string &methodName, ADDRESS_64 param)
 Logs call of method with DWORD parameter. More...
 
void log (const std::string &objName, const std::string &methodName, const std::string &param)
 Logs call of method with Logs call with string parameter. More...
 
void logc (const std::string &comment)
 This method may be called from client code to insert user specific comments. More...
 
void logf (const std::string &objName, const std::string &methodName, const char *format,...)
 Logging of function call with variable arguments. More...
 
void loggingOff ()
 Turns logging off. More...
 
void loggingOn ()
 Turns logging on. More...
 
void resetStartTime ()
 Resets start time so that it will start counting from 0 when the first method is executed. More...
 
void setIndent (int indent)
 Sets indentation for the following logged statements. More...
 

Static Public Member Functions

static std::string icDebugAccessFlags2str (int flags)
 Returns string corresponding to value of flags to IConnectDebug::EAccessFlags.
 
static std::string icDebugAddressFlags2str (int flags)
 Returns string corresponding to value of flags to IConnectDebug::EGetAddressFlags. More...
 
static std::string icDebugEvaluateFlags2str (int flags)
 Returns string corresponding to value of flags to IConnectDebug::EEvaluateFlags.
 
static std::string icDebugSymbolFlags2str (int flags)
 Returns string corresponding to value of flags to IConnectDebug::ESymbolFlags.
 
static std::string icSTypeType2str (int flags)
 Returns string corresponding to enum in STYpe.
 
static std::string lang2str (LogFileLanguage flags)
 Returns string corresponding to CCoverageController::ERangeItem. More...
 

Member Enumeration Documentation

◆ LogFileLanguage

Enum type for logging language selection.

Enumerator
JAVA 

write log statements in Java language (limited support)

PYTHON 

write log statements in Python language

Constructor & Destructor Documentation

◆ CLogger() [1/2]

isys::CLogger::CLogger ( const std::string &  fileName,
LogFileLanguage  language,
bool  isLogToStdOut,
double  timeDiffToIgnore,
const std::string &  header 
)

Opens log file and initializes it.

Logging is ON by default.

Parameters
fileNamename of the logFile
languagedefines syntax used for command logging
isLogToStdOutNOT IMPLEMENTED! (if true, output will be also printed to std out)
timeDiffToIgnoretime delays shorter than this value are not logged. This value should be specified in seconds. Use large value to disable logging of delays.
headerstring containing header of the log file. It may include imports, class and method declarations, so that the generated log file is compilable Java or Python source file. It may as well be empty or include comment only.

◆ CLogger() [2/2]

isys::CLogger::CLogger ( const std::string &  fileName,
LogFileLanguage  language 
)

Opens log file and initializes it.

Logging is ON by default. Time difference to be ignored is set to 1 second by default.

Parameters
fileNamename of the logFile
languagedefines syntax used for command logging

Member Function Documentation

◆ closeLog()

void isys::CLogger::closeLog ( const std::string &  footer)

Closes log file and turns off the logging.

No logging will be done after this call. Log file

Parameters
footerend of Java or Python program, for example closing parantheses in Java. May also be empty or contain comment.

◆ createSType()

void isys::CLogger::createSType ( const std::string &  valueName,
const SType sType 
)

Creates and fills CValueType object.

void createCValueType(const std::string &valueName, const CValueType &value); Creates and fills SType object.

◆ icDebugAddressFlags2str()

static std::string isys::CLogger::icDebugAddressFlags2str ( int  flags)
static

Returns string corresponding to value of flags to IConnectDebug::EGetAddressFlags.

Converts only the most often used values. Useful for logging, but not for generating program code.

◆ isLoggingOn()

bool isys::CLogger::isLoggingOn ( )
inline

Returns if logging is turned on.

Returns
true if logging is enabled, otherwise false

◆ lang2str()

static std::string isys::CLogger::lang2str ( LogFileLanguage  flags)
static

Returns string corresponding to CCoverageController::ERangeItem.

Returns string corresponding to IConnectCoverage::ECoverageRangesTypes. Returns string corresponding to IConnectCoverage::ECoverageStatisticsFlags. Returns string corresponding to IConnectCoverage::EConfigFlags. Returns string corresponding to IConnectCoverage::EGetStatusFlags. Returns string corresponding to logger language settings.

◆ log() [1/3]

void isys::CLogger::log ( const std::string &  objName,
const std::string &  methodName 
)

Logs call of method with no parameter.

See also
logf

◆ log() [2/3]

void isys::CLogger::log ( const std::string &  objName,
const std::string &  methodName,
ADDRESS_64  param 
)

Logs call of method with DWORD parameter.

See also
logf

◆ log() [3/3]

void isys::CLogger::log ( const std::string &  objName,
const std::string &  methodName,
const std::string &  param 
)

Logs call of method with Logs call with string parameter.

See also
logf

◆ logc()

void isys::CLogger::logc ( const std::string &  comment)

This method may be called from client code to insert user specific comments.

The language specific comment character is automatically prepended.

◆ logf()

void isys::CLogger::logf ( const std::string &  objName,
const std::string &  methodName,
const char *  format,
  ... 
)

Logging of function call with variable arguments.

Parameters
objNamename of the object to be used in the generated code. For example 'addrCtrl'.
methodNamename of the method to be used in the generated code. For example "getFunctionAddress" to generate addrCtrl.getFunctionAddress("main") when format string is "s" and additional parameter is "main".
formatformat string, may contain:
  • i - int
  • s - std::string
  • b - bool
  • l - int64_t
  • u - unsigned
  • D - DWORD
  • E - enum, followed by conversion function pointer. If the pointer == NULL, enum is logged as integer

Note: This method can not be called from Python.

◆ loggingOff()

void isys::CLogger::loggingOff ( )

Turns logging off.

Calls to log() methods will produce no output after this call.

See also
loggingOn

◆ loggingOn()

void isys::CLogger::loggingOn ( )

Turns logging on.

See also
loggingOff

◆ resetStartTime()

void isys::CLogger::resetStartTime ( )

Resets start time so that it will start counting from 0 when the first method is executed.

Useful, when we want to repeat script without restarting.

◆ setIndent()

void isys::CLogger::setIndent ( int  indent)

Sets indentation for the following logged statements.

Call with argument 0 to disable indentation.

Parameters
indentthe number of spaces used for indentation