TEMU
4.4
The Terma Emulator
|
#include "temu-c/Support/Attributes.h"
#include "temu-c/Support/Objsys.h"
#include <stdarg.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | temu_logDebug temu_logDebugFunc |
#define | teLC_FirstUserCat 8 |
#define | teLC_DefaultCat 0 |
#define | teLC_SimCat 1 |
#define | teLC_TargetCat 2 |
#define | teLC_ConfigCat 3 |
Typedefs | |
typedef enum temu_LogLevel | temu_LogLevel |
Enumerations | |
enum | temu_LogLevel { teLL_Fatal = 0, teLL_Error, teLL_Warning, teLL_Info, teLL_Trace, teLL_Debug } |
Functions | |
TEMU_API void | temu_logSetLevel (temu_LogLevel LogLevel) |
TEMU_API void | temu_logSetFunc (void(*LogFunc)(const char *)) |
TEMU_API void | temu_logSetAdvancedFunc (void(*LogFunc)(void *, temu_Object *, unsigned, temu_LogLevel, const char *), void *UserData) |
TEMU_API void | temu_logSetDefaultFile (FILE *FP) |
TEMU_API void | temu_logSetColour (int Enable) |
TEMU_API void | temu_logFatal (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf |
TEMU_API void TEMU_API void | temu_logError (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void | temu_logWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logTrace (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logDebugFunc (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void | temu_logToCategoryVA (const void *Obj, unsigned Category, temu_LogLevel Severity, const char *Msg, va_list Args) |
TEMU_API void | temu_logSetSeverity (void *Obj, unsigned Category, temu_LogLevel Severity) |
TEMU_API void | temu_logToCategory (const void *Obj, unsigned Category, temu_LogLevel Severity, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void | temu_logSimFatal (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void | temu_logSimError (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logSimWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logSimInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logTargetFatal (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logTargetError (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logTargetWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logTargetInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logConfigFatal (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logConfigError (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logConfigWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void | temu_logConfigInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API temu_LogLevel | temu_objectGetLogLevel (void *Obj, unsigned Category) |
TEMU_API void | temu_objectSetLogLevel (void *Obj, unsigned Category, temu_LogLevel LogLevel) |
TEMU logging functions. TEMU provides a logging facility to log messages from models. These messages can be of a number of severity levels and will be assigned to a model object. When printing the message will be formatted as follows: "<severity> : <object> : message\n", where <severity> is one of debug, info, warning, error and critical and <object> is the name of the object generating the log message.
TEMU provides a "critical" log message, these messages are critical in the sense that after they have been logged, the emulator will terminate abnormally. Critical messages should never happen normally are typically placed in unreachable code locations.
Error messages imply that something failed but that the caller of the failed function is expected to take action in some way. Typical case is when opening a file (e.g. an SREC or ELF binary) specified by the user and the file did not exist.
Warning message exist to notify the user about something that may be an issue, but not necessarily is. An example is in the object system temu_checkSanity function, which will check whether objects are properly configured by being fully connected.
Info messages are normal messages, that exist solely to provide information to the user. For example, a model may print status info after it has been created.
Debug messages should not occur during normal use, and the debug function will be a static inline function with no body when building a model with -DNDEBUG. This is important, because the compiler will eliminate the call to the empty function, while still remaining fully typesafe and NOT being a macro.
#define teLC_ConfigCat 3 |
#define teLC_DefaultCat 0 |
#define teLC_FirstUserCat 8 |
#define teLC_SimCat 1 |
#define teLC_TargetCat 2 |
#define temu_logDebug temu_logDebugFunc |
typedef enum temu_LogLevel temu_LogLevel |
Logging levels corresponds roughly to some of the RFC 5424 severity levels.
enum temu_LogLevel |
Logging levels corresponds roughly to some of the RFC 5424 severity levels.
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigError | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log configuration error
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigFatal | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log configuration fatal error
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigInfo | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log configuration info
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigWarning | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log configuration warning
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logDebugFunc | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log a message with debug severity
Obj | is the source of the log message |
Msg | The message to log |
Log a message with error severity
Obj | is the source of the log message |
Msg | The message to log |
TEMU_API void temu_logFatal | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log a message with fatal severity; The program will terminate after calling this
Obj | is the source of the log message |
Msg | The message to log |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logInfo | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log a message with info severity
Obj | is the source of the log message |
Msg | The message to log |
TEMU_API void temu_logSetAdvancedFunc | ( | void(*)(void *, temu_Object *, unsigned, temu_LogLevel, const char *) | LogFunc, |
void * | UserData | ||
) |
Set advanced logging function.
It is possible to provide a custom function for handling logging messages from TEMU. This can be used by a simulator that provides a centralized logging facility to also handle TEMU logging messages. By default, the messages will be printed to stderr using fputs.
The advanced logging function does not get messages with a terminating linefeed. In addition, the function receives the object, category and log level as its own parameters.
The message does not contain object name / time stamps. The integrator would be expected to extract the time stamp from the objects time source if set.
LogFunc will take the following parameters:
User data:: Void pointer passed to UserData parameter (may be NULL). Object pointer:: Pointer to object issuing the log message (may be NULL). Category:: Category id of log message. Log level:: Severity of logging message. Message:: The log message, as a '\0' terminated string.
LogFunc | Logging function to use. NULL to restore the default. |
UserData | User data to pass to the logging functions first parameter. |
TEMU_API void temu_logSetColour | ( | int | Enable | ) |
Enable colours on logging
Enable | 0 to disable colours, 1 to enable |
TEMU_API void temu_logSetDefaultFile | ( | FILE * | FP | ) |
Set the logging file for the default logging function. Pass NULL to restore default (stderr).
FP | Logging file pointer, NULL to restore default. |
TEMU_API void temu_logSetFunc | ( | void(*)(const char *) | LogFunc | ) |
Set logging function.
It is possible to provide a custom function for handling logging messages from TEMU. This can be used by a simulator that provides a centralized logging facility to also handle TEMU logging messages. By default, the messages will be printed to stderr using fputs. Note that messages will be terminated by "\n\0", so if your logging system adds a linefeed, the message may need to be transformed.
LogFunc | Logging function to use. NULL to restore the default. |
TEMU_API void temu_logSetLevel | ( | temu_LogLevel | LogLevel | ) |
Set logging level. Messages will be logged if they are of the set level or higher priority.
LogLevel | The logging level. |
TEMU_API void temu_logSetSeverity | ( | void * | Obj, |
unsigned | Category, | ||
temu_LogLevel | Severity | ||
) |
Set severity for specific category.
Obj | Object for which to modify logging severity |
Category | Category to change severity for (e.g. teLC_DefaultCat) |
Severity | The log level for which messages shall be emitted. |
TEMU_API void TEMU_API void TEMU_API void temu_logSimError | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log simulation error
Obj | Object |
Msg | Printf formatted message string |
Log fatal issue Fatal messages result in termination of the program after the message.
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logSimInfo | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log simulation info
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logSimWarning | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log simulation warning
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetError | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log target error
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetFatal | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log target fatal error This should typically never happen, but it may be convenient in some cases.
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetInfo | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log target info
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetWarning | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log target warning
Obj | Object |
Msg | Printf formatted message string |
TEMU_API void temu_logToCategory | ( | const void * | Obj, |
unsigned | Category, | ||
temu_LogLevel | Severity, | ||
const char * | Msg, | ||
... | |||
) |
Log message in the numbered category
Obj | Object that is the source of the log message |
Category | Category of message (e.g. teLC_DefaultCat ) |
Severity | The log level for which the message shall be emitted. |
Msg | Printf formatted message string. |
TEMU_API void temu_logToCategoryVA | ( | const void * | Obj, |
unsigned | Category, | ||
temu_LogLevel | Severity, | ||
const char * | Msg, | ||
va_list | Args | ||
) |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTrace | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log a message with trace severity
Obj | is the source of the log message |
Msg | The message to log |
TEMU_API void TEMU_API void TEMU_API void temu_logWarning | ( | const void * | Obj, |
const char * | Msg, | ||
... | |||
) |
Log a message with warning severity
Obj | is the source of the log message |
Msg | The message to log |
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API temu_LogLevel temu_objectGetLogLevel | ( | void * | Obj, |
unsigned | Category | ||
) |
Get object specific logging level for category
Obj | Object |
Category | Category |
Category
TEMU_API void temu_objectSetLogLevel | ( | void * | Obj, |
unsigned | Category, | ||
temu_LogLevel | LogLevel | ||
) |
Set object specific logging level for category
Obj | Object |
Category | Category |
LogLevel | Level to set for the given Category |