ThingWorx C SDK
Classes | Macros | Typedefs | Enumerations | Functions
twLogger.h File Reference

Structure definitions and function prototypes for the ThingWorx logging facility. More...

#include "twOSPort.h"
#include "twErrors.h"
#include <stdint.h>

Go to the source code of this file.

Classes

struct  twLogger
 ThingWorx Logger singleton structure definition. More...
 

Macros

#define twLogger_H
 

Typedefs

typedef void(* log_function) (enum LogLevel level, const char *timestamp, const char *message)
 Signature for logging function to be called when twLog() is invoked. More...
 
typedef struct twLogger twLogger
 ThingWorx Logger singleton structure definition.
 

Enumerations

enum  LogLevel {
  TW_TRACE, TW_DEBUG, TW_INFO, TW_WARN,
  TW_ERROR, TW_FORCE, TW_AUDIT
}
 Log message level enumeration. More...
 

Functions

twLoggertwLogger_Instance ()
 Gets a pointer to the twLogger singleton and creates a new one if it hasn't been created already. More...
 
int twLogger_Delete ()
 Frees all memory associated with the twLogger singleton. More...
 
int twLogger_SetLevel (enum LogLevel level)
 Sets the ::twLogger#LogLevel of the twLogger singleton. More...
 
int twLogger_SetFunction (log_function f)
 Sets the ::twLogger#log_function of the twLogger singleton. More...
 
int twLogger_SetIsVerbose (char val)
 Sets the twLogger::isVerbose flag of the twLogger singleton. More...
 
void twLog (enum LogLevel level, const char *format,...)
 Logs a message. More...
 
void twLogHexString (const char *msg, char *preamble, int32_t length)
 Logs a hex string message. More...
 
void twLogMessage (void *m, char *preamble)
 Logs a generic string message. More...
 
char * twCodeToString (enum msgCodeEnum m)
 Helper function to convert a msgCodeEnum to a string. More...
 
char * twEntityToString (enum entityTypeEnum m)
 Helper function to convert a entityTypeEnum to a string. More...
 
char * twCharacteristicToString (enum characteristicEnum m)
 Helper function to convert a characteristicEnum to a string. More...
 

Detailed Description

Structure definitions and function prototypes for the ThingWorx logging facility.

Macro Definition Documentation

#define twLogger_H

Prevent multiple inclusions

Typedef Documentation

typedef void(* log_function) (enum LogLevel level, const char *timestamp, const char *message)

Signature for logging function to be called when twLog() is invoked.

Parameters
[in]levelThe LogLevel of the log message.
[in]timestampThe timestamp of the log message.
[in]messageThe log message text.
Returns
Nothing.

Enumeration Type Documentation

enum LogLevel

Log message level enumeration.

Enumerator
TW_TRACE 

Application execution tracing.

TW_DEBUG 

Debug messages for development.

TW_INFO 

General information messages.

TW_WARN 

Warning messages.

TW_ERROR 

Error messages.

TW_FORCE 

TBD

TW_AUDIT 

TBD

Function Documentation

char* twCharacteristicToString ( enum characteristicEnum  m)

Helper function to convert a characteristicEnum to a string.

Parameters
[in]mThe characteristicEnum to convert.
Returns
A string corresponding to m.
Note
The returned string is allocated on the stack.
char* twCodeToString ( enum msgCodeEnum  m)

Helper function to convert a msgCodeEnum to a string.

Parameters
[in]mThe msgCodeEnum to convert.
Returns
A string corresponding to m.
Note
The returned string is allocated on the stack.
char* twEntityToString ( enum entityTypeEnum  m)

Helper function to convert a entityTypeEnum to a string.

Parameters
[in]mThe entityTypeEnum to convert.
Returns
A string corresponding to m.
Note
The returned string is allocated on the stack.
void twLog ( enum LogLevel  level,
const char *  format,
  ... 
)

Logs a message.

Parameters
[in]levelThe LogLevel of the message.
[in]formatThe format of the message.
[in]...A va_list of messages to log.
Returns
Nothing.
int twLogger_Delete ( )

Frees all memory associated with the twLogger singleton.

Returns
#TW_OK if successful, positive integral on error code (see twErrors.h) if an error was encountered.
twLogger* twLogger_Instance ( )

Gets a pointer to the twLogger singleton and creates a new one if it hasn't been created already.

Returns
A pointer to the new or existing twLogger singleton.
int twLogger_SetFunction ( log_function  f)

Sets the ::twLogger#log_function of the twLogger singleton.

Parameters
[in]fThe log_function() to use.
Returns
#TW_OK if successful, positive integral on error code (see twErrors.h) if an error was encountered.
int twLogger_SetIsVerbose ( char  val)

Sets the twLogger::isVerbose flag of the twLogger singleton.

Parameters
[in]valTRUE enables verbose logging, FALSE disables verbose logging.
Returns
#TW_OK if successful, positive integral on error code (see twErrors.h) if an error was encountered.
int twLogger_SetLevel ( enum LogLevel  level)

Sets the ::twLogger#LogLevel of the twLogger singleton.

Parameters
[in]levelThe LogLevel to set the twLogger to.
Returns
#TW_OK if successful, positive integral on error code (see twErrors.h) if an error was encountered.
void twLogHexString ( const char *  msg,
char *  preamble,
int32_t  length 
)

Logs a hex string message.

Parameters
[in]msgThe message to log.
[in]preamble#TRUE enables message preamble, #FALSE disables message preamble.
[in]lengthThe length of the message.
Returns
Nothing.
void twLogMessage ( void *  m,
char *  preamble 
)

Logs a generic string message.

Parameters
[in]mThe message to log.
[in]preamble#TRUE enables message preamble, #FALSE disables message preamble.
Returns
Nothing.