# debug

The debug class is automatically created and can be globally accessed by using the reference * debug. It has to be freed after the iomux Run function in the main class.
In your app code, you shouldn't use the debug class in release builds directly,
but instead the log functions of your AppInstance class.
If you use VisualGDB or Valgrind to run your App, the logs are written to STDOUT.
Otherwise they are written to a logfile under /var/log/apps/appname-timestamp.txt.
There are up to 5 log files for each App and each log file can have a maximum size of 5 MB.

## Logs within an AppInstance object

The AppInstance object itself provides log functions, where the appName and appDomain are always printed
to make out different AppInstance objects.
In addition, these log functions do only write logs to the log file, if the corresponding log flag
for the application is set within the taskmanager or your code.
See appservice.htm for more information.

## LOG_FLAGS and IInstanceLog base class

See appservice.htm for more information.

## The following functions can be used to debug data independent of the current log flags.

void printf(const char * format, ...)
  Can be used like the standard printf.
void hexdump(const void * buffer, size_t size)
  Prints a hexdump of the given buffer with the given size.
void appPrintf(const char * appName, const char * appDomain, const char * format, ...)
  The same as printf, but appName@appDomain are also printed. This method is used
  to debug different AppInstance objects.
void appPrintfV(const char * appName, const char * appDomain, const char * format, va_list ap)
  The same as appPrintf, but with an va_list ap as last argument.
void appHexdump(const char * appName, const char * appDomain, const void * buffer, size_t size)
  The same as hexdump, but appName@appDomain are also printed. This method is used
  to debug different AppInstance objects.
void SetLogging(bool on)
  Disables or enables the complete logging of the whole app. This might be usefull to prevent some important logs to get lost.
void SetHexdump(bool on)
  Disables or enables all hexdumps within the whole app. This might be usefull if you just want to see the call flow of functions without data.
void SetLogFileSize(off_t size)
  Set the maximum log file size for the app. This setting is normally controlled by the manager.
Example:
  `

      debug->printf("MyClass::TestFunction %s %x", "Hallo", 1234);
      // 2016-11-07 13:29:05.663103 MyClass::TestFunction Hallo 0x42d
      byte buf[4];
      debug->HexDump(buf, sizeof(buf));
      // 2016-11-07 13:29:05.663103 Hexdump of address 0x7EFFFC60, 4 bytes:
      // 2016-11-07 13:29:05.663301 0x00000000   00 00 00 00

  `