T-EMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Typedefs | Enumerations | Functions
Logging.h File Reference

Go to the source code of this file.

Typedefs

typedef enum temu_LogLevel temu_LogLevel
 

Enumerations

enum  temu_LogLevel {
  teLL_Fatal = 0, teLL_Critical = 0, teLL_Error, teLL_Warning,
  teLL_Info, teLL_Debug
}
 

Functions

void temu_logSetLevel (temu_LogLevel LogLevel)
 
void temu_logSetFunc (void(*LogFunc)(const char *))
 
void temu_logFatal (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf
 
void void temu_logCritical (const void *Obj, const char *Msg,...) __attribute__((noreturn)) __attribute__((format(printf
 
void void __attribute__ ((deprecated))
 
void temu_logError (const void *Obj, const char *Msg,...) __attribute__((format(printf
 
void void temu_logWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf
 
void void void temu_logInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf
 
void void void void temu_logDebugFunc (const void *Obj, const char *Msg,...) __attribute__((format(printf
 
void void void void void temu_logDebug (const void *Obj, const char *Msg,...) __attribute__((format(printf
 

Detailed Description

T-EMU logging functions. T-EMU 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.

T-EMU 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.

Definition in file Logging.h.

Typedef Documentation

Logging levels corresponds roughly to some of the RFC 5424 severity levels.

Enumeration Type Documentation

Logging levels corresponds roughly to some of the RFC 5424 severity levels.

Enumerator
teLL_Fatal 

Fatal, emulator cannot keep on running.

teLL_Critical 

Critical, emulator cannot keep on running.

teLL_Error 

Error happened, in principle critical but up to user.

teLL_Warning 

Warnings.

teLL_Info 

Normal messages.

teLL_Debug 

Debug.

Definition at line 59 of file Logging.h.

Function Documentation

void void __attribute__ ( (deprecated)  )
void void temu_logCritical ( const void *  Obj,
const char *  Msg,
  ... 
)
void void void void void temu_logDebug ( const void *  Obj,
const char *  Msg,
  ... 
)
void void void void temu_logDebugFunc ( const void *  Obj,
const char *  Msg,
  ... 
)
void temu_logError ( const void *  Obj,
const char *  Msg,
  ... 
)
void temu_logFatal ( const void *  Obj,
const char *  Msg,
  ... 
)
void void void temu_logInfo ( const void *  Obj,
const char *  Msg,
  ... 
)
void temu_logSetFunc ( void(*)(const char *)  LogFunc)

Set logging function.

It is possible to provide a custom function for handling logging messages from T-EMU. This can be used by a simulator that provides a centralised logging facility to also handle T-EMU 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.

Parameters
LogFuncLogging function to use.
void temu_logSetLevel ( temu_LogLevel  LogLevel)

Set logging level. Messages will be logged if they are of the set level or higher priority.

Parameters
LogLevelThe logging level.
void void temu_logWarning ( const void *  Obj,
const char *  Msg,
  ... 
)