Logging

The SFLOG module provide the logging system functionality to NumXL SDK, and can be used as well by your application. The logging subsystem is implemented after the common "log4j" library, and support similar configuration and functionality.

Furthermore, the library is thread-safe, and if more than one process try to write to the same file, the system will create a new file for the second process to avoid collision.

Configuration file

In the main configuration file (e.g. "MyApp.conf"), locate the section for logging (i.e. [LOG]), and edit the different entries to suite your exact needes (e.g. Layout, level, etc.). Here is an example:

# LOG LEVELS: OFF=0, TRACE=1, DEBUG=2, INFO=3, WARN=4, ERROR=5, FATAL=6, ALL= 7
[LOG]
FILE = MyApp.log
LEVEL = 7
BACKUPFILES = 7
MAXSIZE = 512000
COMPRESSION = false
LAYOUT = "%d %5p [%t] - %F(%L) - %c - %m%n"
		
Logging Level
SFLOG_ALL  0 Enable all logging messages (info, debug, trace, warning and error) 
SFLOG_TRACE 1 Enable trace level logging: trace, debug, info, warning, error and fatal error messages. 
SFLOG_DEBUG 2 Enable debug level logging: debug, info, warning, error and fatal error messages. 
SFLOG_INFO 3 Enable information level logging: info, warning, error, and fatal error messages.
SFLOG_WARN 4 Enable warning level logging: warning, error and fatal error messages.
SFLOG_ERROR 5 Enable error level logging: error and fatal error messages. 
SFLOG_FATAL 6 Enable fatal or critical level logging.
SFLOG_OFF 7 Disable all logging messages
Requirements
Header SFLogger.H
Library SFLOG.LIB
DLL SFLOG.DLL
Example
#include <iostream>
#include "SFMacros.h"
#include "SFLogger.h"

using namespace std;

#define LOG_TRACE(x)  \
    SFLOG_logMsg(SFLOG_TRACE, __FILE__,__FUNCTION__,__FUNCSIG__,__LINE__,x);    

#define LOG_ERROR(x)  \
    SFLOG_logMsg(SFLOG_ERROR, __FILE__,__FUNCTION__,__FUNCSIG__,__LINE__,x);    

int main(){
  int nRet= NDK_FAILED; 

  string szAppName="MyLogExample";
  string szPath = "C:\\temp";

  nRet = SFLOG_Init(szAppName.c_str(),  // Use MyLogExample.conf file, and name the log file as MyLOgExample.log
  		    szPath.c_str()	// Use C:\temp folder to create the log	file(s)
                    );
  if(nRet < NDK_SUCCESS){
  	std::cerr << "Initializing the logging facility failed, exit" << std::endl;
    exit(-1);
  }
  SFLOG_TRACE("SF Logging facilty has been initialized successfully");
  
  .....

  // Change the logging level to Error
  nRet = SFLOG_SETLEVEL(SFLOG_ERROR);
  if( nRet < NDK_SUCCESS){
    SFLOG_ERROR("Changing logging level failed");
  }
  
  // Close the log file and shutdown the logging
  nRet = SFLOG_Shutdown();

  exit(0;)
}
   

The NumXLAPI.SFLOG wrapper class provides the logging system functionality to NumXL SDK, and can be used as well by your application. The logging subsystem is implemented after the common "log4j" library, and support similar configuration and functionality.

Furthermore, the library is thread-safe, and if more than one process try to write to the same file, the system will create a new file for the second process to avoid collision.

Configuration file

In the main configuration file (e.g. "MyApp.conf"), locate the section for logging (i.e. [LOG]), and edit the different entries to suite your exact needes (e.g. Layout, level, etc.). Here is an example:

# LOG LEVELS: OFF=0, TRACE=1, DEBUG=2, INFO=3, WARN=4, ERROR=5, FATAL=6, ALL= 7
[LOG]
FILE = MyApp.log
LEVEL = 7
BACKUPFILES = 7
MAXSIZE = 512000
COMPRESSION = false
LAYOUT = "%d %5p [%t] - %F(%L) - %c - %m%n"
		
Logging Level
namespace NumXLAPI{
  . . .
  public enum SFLOG_LEVEL
  {
    SFLOG_ALL=0,
    SFLOG_TRACE=1,
    SFLOG_DEBUG=2,
    SFLOG_INFO=3,
    SFLOG_WARN=4,
    SFLOG_ERROR=5,
    SFLOG_FATAL=6,
    SFLOG_OFF=7
  }