winIDEA SDK
|
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 ¶m) |
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... | |
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.
fileName | name of the logFile |
language | defines syntax used for command logging |
isLogToStdOut | NOT IMPLEMENTED! (if true, output will be also printed to std out) |
timeDiffToIgnore | time delays shorter than this value are not logged. This value should be specified in seconds. Use large value to disable logging of delays. |
header | string 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. |
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.
fileName | name of the logFile |
language | defines syntax used for command logging |
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
footer | end of Java or Python program, for example closing parantheses in Java. May also be empty or contain comment. |
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.
|
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.
|
inline |
Returns if logging is turned on.
|
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.
void isys::CLogger::log | ( | const std::string & | objName, |
const std::string & | methodName | ||
) |
Logs call of method with no parameter.
void isys::CLogger::log | ( | const std::string & | objName, |
const std::string & | methodName, | ||
ADDRESS_64 | param | ||
) |
Logs call of method with DWORD parameter.
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.
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.
void isys::CLogger::logf | ( | const std::string & | objName, |
const std::string & | methodName, | ||
const char * | format, | ||
... | |||
) |
Logging of function call with variable arguments.
objName | name of the object to be used in the generated code. For example 'addrCtrl'. |
methodName | name 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" . |
format | format string, may contain:
|
Note: This method can not be called from Python.
void isys::CLogger::loggingOff | ( | ) |
void isys::CLogger::loggingOn | ( | ) |
Turns logging on.
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.
void isys::CLogger::setIndent | ( | int | indent | ) |
Sets indentation for the following logged statements.
Call with argument 0 to disable indentation.
indent | the number of spaces used for indentation |