TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Logging.h File Reference
#include <stdio.h>
#include <stdarg.h>
#include "temu-c/Support/Attributes.h"
Include dependency graph for Logging.h:
This graph shows which files directly or indirectly include this file:

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_Critical = 0, teLL_Error, teLL_Warning,
  teLL_Info, teLL_Debug
}
 

Functions

TEMU_API void temu_logSetLevel (temu_LogLevel LogLevel)
 
TEMU_API void temu_logSetFunc (void(*LogFunc)(const char *))
 
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__((format(printf
 temu_logFatal Log a message with fatal severity; The program will terminate after calling this More...
 
TEMU_API void TEMU_API void temu_logCritical (const void *Obj, const char *Msg,...) __attribute__((format(printf
 
TEMU_API void TEMU_API void __attribute__ ((deprecated))
 
TEMU_API void temu_logError (const void *Obj, const char *Msg,...) __attribute__((format(printf
 temu_logError Log a message with error severity More...
 
TEMU_API void TEMU_API void temu_logWarning (const void *Obj, const char *Msg,...) __attribute__((format(printf
 temu_logWarning Log a message with warning severity More...
 
TEMU_API void TEMU_API void
TEMU_API void 
temu_logInfo (const void *Obj, const char *Msg,...) __attribute__((format(printf
 temu_logInfo Log a message with info severity More...
 
TEMU_API void TEMU_API void
TEMU_API void TEMU_API void 
temu_logDebugFunc (const void *Obj, const char *Msg,...) __attribute__((format(printf
 temu_logDebugFunc Log a message with debug severity More...
 
TEMU_API void temu_logToCategoryVA (const void *Obj, unsigned Category, temu_LogLevel Severity, const char *Msg, va_list Args)
 
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__((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__((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__((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)
 

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.

Macro Definition Documentation

#define teLC_ConfigCat   3

Definition at line 218 of file Logging.h.

#define teLC_DefaultCat   0

Definition at line 215 of file Logging.h.

#define teLC_FirstUserCat   8

Definition at line 213 of file Logging.h.

#define teLC_SimCat   1

Definition at line 216 of file Logging.h.

#define teLC_TargetCat   2

Definition at line 217 of file Logging.h.

#define temu_logDebug   temu_logDebugFunc

Definition at line 168 of 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 (deprecated)

teLL_Error 

Error happened, in principle critical but up to user.

teLL_Warning 

Warnings.

teLL_Info 

Normal messages.

teLL_Debug 

Debug.

Definition at line 63 of file Logging.h.

Function Documentation

TEMU_API void TEMU_API void __attribute__ ( (deprecated)  )
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

Parameters
ObjObject 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

Parameters
ObjObject 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

Parameters
ObjObject 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

Parameters
ObjObject Msg Printf formatted message string
TEMU_API void TEMU_API void temu_logCritical ( const void *  Obj,
const char *  Msg,
  ... 
)
TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logDebugFunc ( const void *  Obj,
const char *  Msg,
  ... 
)

temu_logDebugFunc Log a message with debug severity

Warning
This function is intended for internal use only. Do not call this directly. Use temu_logDebug() instead.
Parameters
Objis the source of the log message
MsgThe message to log
TEMU_API void temu_logError ( const void *  Obj,
const char *  Msg,
  ... 
)

temu_logError Log a message with error severity

Parameters
Objis the source of the log message
MsgThe message to log
TEMU_API void temu_logFatal ( const void *  Obj,
const char *  Msg,
  ... 
)

temu_logFatal Log a message with fatal severity; The program will terminate after calling this

Parameters
Objis the source of the log message
MsgThe message to log
TEMU_API void TEMU_API void TEMU_API void temu_logInfo ( const void *  Obj,
const char *  Msg,
  ... 
)

temu_logInfo Log a message with info severity

Parameters
Objis the source of the log message
MsgThe message to log
TEMU_API void temu_logSetColour ( int  Enable)

Enable colours on logging

Parameters
Enable0 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).

Parameters
FPLogging 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 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. 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.

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

Log simulation error

Parameters
ObjObject Msg Printf formatted message string
TEMU_API void TEMU_API void temu_logSimFatal ( const void *  Obj,
const char *  Msg,
  ... 
)

Log fatal issue Fatal messages result in termination of the program after the message.

Parameters
ObjObject 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

Parameters
ObjObject 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

Parameters
ObjObject 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

Parameters
ObjObject 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.

Parameters
ObjObject 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

Parameters
ObjObject 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

Parameters
ObjObject 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

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_logWarning ( const void *  Obj,
const char *  Msg,
  ... 
)

temu_logWarning Log a message with warning severity

Parameters
Objis the source of the log message
MsgThe 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 
)
TEMU_API void temu_objectSetLogLevel ( void *  Obj,
unsigned  Category,
temu_LogLevel  LogLevel 
)