NumXL SDK - Logging API
Configurations

API for Initializing, configuring, and shutdown the logging facility. More...

Macros

#define SFLOG_INIT   SFLOG_INITW
 An alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant.
 

Functions

int __stdcall SFLOG_INITW (LPCWSTR szAppName, LPCWSTR szLogDir, DWORD dwBackupFiles, size_t ulMaxFileSize, unsigned int *pClientToken)
 Initializes the logging facility of the NumXL SDK using Unicode strings for the logging base filename and directory..
 
int __stdcall SFLOG_INITA (LPCSTR szAppName, LPCSTR szLogDir, DWORD dwBackupFiles, size_t ulMaxFileSize, unsigned int *pClientToken)
 Initialize the logging system for SDK. This is often the first API call that an application makes and is a prerequisite for other logging APIs.
 
int __stdcall SFLOG_SHUTDOWN (unsigned int uClientToken)
 Shutdown and release resources allocated by logging system.
 
int __stdcall SFLOG_GETLEVEL (unsigned int *nLevel)
 retieve the current logging level (or threshold) in the logging system.
 
int __stdcall SFLOG_SETLEVEL (unsigned int uClientToken, unsigned int nLevel)
 set the new logging level in the SDK
 

Detailed Description

The NumXL SDK logging subsystem definie a logging level to determine whether a message is written to the log file or not. The numeric integer value of the logging level is represented by the value of one of those macros.

Macro Definition Documentation

◆ SFLOG_INIT

#define SFLOG_INIT   SFLOG_INITW

Function Documentation

◆ SFLOG_GETLEVEL()

int __stdcall SFLOG_GETLEVEL ( unsigned int * nLevel)
Parameters
[out]nLevel(Required) Is the currently-selected logging level (e.g. debug, info, trace). For a full list, see Logging Levels
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDunknown error
NDK_INVALID_ARGthe nLevel value (aka., address) is NULL.
See also
SFLOG_SETLEVEL

querys and returns the current logging level in the logging subsystem

Remarks
  1. For convenience, you may wish to define few macros to automate the logging further. For example:
Requirements
Target Platform Windows
Header SFLOG.h (include Windows.h)
Library SFLOG.lib
DLL SFLOG.dll

◆ SFLOG_INITA()

int __stdcall SFLOG_INITA ( LPCSTR szAppName,
LPCSTR szLogDir,
DWORD dwBackupFiles,
size_t ulMaxFileSize,
unsigned int * pClientToken )
Parameters
[in]szAppName(Required) Is the application name (user-defined), but must match the configuration base filename
[in]szLogDir(Optional) Is the full (absolute) path of the log file directory. If missing (i.e. NULL), SFLOG_Init uses the default temp directory in the current user's profile
[in]dwBackupFiles(Required) Is the number of backup log files to keep, before we overwite the oldest one
[in]ulMaxFileSize(Required) Is the maximym file size, before a rolling a new file starts (in bytes)
[out]pClientTokenAn integer token used during the logging shutdown
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_SKIP_INITsuccess with a warning
NDK_FAILEDerror
NDK_DATAPATH_INVALIDerror
See also
SFLOG_SHUTDOWN, SFLOG_INIT
Note
The SFLOG.h header defines SFLOG_INIT as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant.
Remarks
  1. The argument szBaseName value must be a vaild base logging filename, so it can't include the following characters: backslash (\), slash(/), colon(:), astrick(*), question mark(?), double-quote("), left-angle(<), right-angle(>), or vertical pipeline(|).
  2. The first call to this function initializes the logging system, and all subsequent calls to SFLOG_INIT are ignored (returns NDK_SKIP_INIT).
  3. If the value of szLogDir argument is missing (empty or NULL), the function will use the default temp directory in the current user's profile.
  4. For multiple concurrent running processes (e.g. custom application, NumXL Add-in, etc.), the logging system will open/create a separate log file (with a unique suffix) for each process.
  5. To reset the logging system, call the SFLOG_SHUTDOWN first, then call the SFLOG_INIT.
Requirements
Target Platform Windows
Header SFLOG.h (include Windows.h)
Library SFLOG.lib
DLL SFLOG.dll
Examples
log_ascii.cpp.

◆ SFLOG_INITW()

int __stdcall SFLOG_INITW ( LPCWSTR szAppName,
LPCWSTR szLogDir,
DWORD dwBackupFiles,
size_t ulMaxFileSize,
unsigned int * pClientToken )
Parameters
[in]szAppName(Required) Is the application name (user-defined), but must match the configuration base filename
[in]szLogDir(Optional) Is the full (absolute) path of the log file directory. If missing (i.e. NULL), SFLOG_Init uses the default temp directory in the current user's profile
[in]dwBackupFiles(Required) Is the number of backup log files to keep, before we overwrite the oldest one
[in]ulMaxFileSize(Required) Is the maximym file size, before a rolling a new file starts (in bytes)
[out]pClientTokenan integer token used during the logging shutdown
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDunknown error
NDK_DATAPATH_INVALIDthe path in szLogDir is either invalid or does not exists.
NDK_SKIP_INITthe logging subsystem has been called earlier, so nothing to be done here. The pClientToken is not set.
See also
SFLOG_SHUTDOWN, SFLOG_INITA

Initialize the logging system and accepts a unicode filename and path.

Note
The SFLOG.h header defines SFLOG_INIT as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant.
Remarks
  1. This is often the first API call that an application makes and is a prerequisite for other logging APIs.
  2. The argument szBaseName value must be a vaild base logging filename, so it can't include the following characters: backslash (\), slash(/), colon(:), astrick(*), question mark(?), double-quote("), left-angle(<), right-angle(>), or vertical pipeline(|).
  3. The first call to this function initializes the logging system, and all subsequent calls to SFLOG_INIT are ignored (returns NDK_SKIP_INIT).
  4. If the value of szLogDir argument is missing (empty or NULL), the function will use the default temp directory in the current user's profile.
  5. For multiple concurrent running processes (e.g. custom application, NumXL Add-in, etc.), the logging system will open/create a separate log file (with a unique suffix) for each process.
  6. To reset the logging system, call the SFLOG_SHUTDOWN first, then call the SFLOG_INIT.
A sample code
13 unsigned int uClientToken=0;
14 int nRetCode = SFLOG_INITW(L"testapp",L"C:\\temp", 7, (3*1024*1024),&uClientToken);
15 if(nRetCode == NDK_SUCCESS)
16 {
Requirements
Target Platform Windows
Header SFLOG.h (include Windows.h)
Library SFLOG.lib
DLL SFLOG.dll
Examples
log_init.cpp, and log_wchar.cpp.

◆ SFLOG_SETLEVEL()

int __stdcall SFLOG_SETLEVEL ( unsigned int uClientToken,
unsigned int nLevel )
Parameters
[in]uClientToken(Required) Is the logging system token id (acquired during initialization).
[in]nLevel(Required) Is the new logging level (e.g. debug, info, trace). For a full list, see Logging Levels
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDunknown error
NDK_INVALID_ARGthe value of nLevel is out of range (i.e., nLevel < SFLOG_ALL or nLevel > SFLOG_OFF)
See also
SFLOG_GETLEVEL

sets the current logging level in the logging subsystem

Note

Remarks
  1. For convenience, you may wish to define few macros to automate the logging further. For example:
Requirements
Target Platform Windows
Header SFLOG.h (include Windows.h)
Library SFLOG.lib
DLL SFLOG.dll

◆ SFLOG_SHUTDOWN()

int __stdcall SFLOG_SHUTDOWN ( unsigned int uClientToken)
Parameters
[in]uClientToken(Required) Is the logging system token id (acquired during initialization).
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
NDK_UNINITIALIZEDerror
NDK_INVALID_TOKENerror
See also
SFLOG_INITA, SFLOG_INITW, SFLOG_INIT

write all the cache logs to the file and closed the log file.

Examples
std::wstring szAppName = L"testapp";
std::wstring szLogDir =L"C:\\temp";
DWORD dwBackupFiles=7;
size_t ulMaxFileSize= (1024 * 1024);
unsigned int uClientToken=0;
int nRetCode = SFLOG_INITW(szAppName.c_str(),szLogDir.c_str(), dwBackupFiles, ulMaxFileSize, &uClientToken);
if(nRetCode == NDK_SUCCESS){
SFLOG_SHUTDOWN(uClientToken);
}
#define NDK_SUCCESS
SUCCESS return code.
Definition SFLOG.h:36
int __stdcall SFLOG_INITW(LPCWSTR szAppName, LPCWSTR szLogDir, DWORD dwBackupFiles, size_t ulMaxFileSize, unsigned int *pClientToken)
Initializes the logging facility of the NumXL SDK using Unicode strings for the logging base filename...
Definition SFLog.cpp:115
int __stdcall SFLOG_SHUTDOWN(unsigned int uClientToken)
Shutdown and release resources allocated by logging system.
Definition SFLog.cpp:296
Requirements
Target Platform Windows
Header SFLOG.h (include Windows.h)
Library SFLOG.lib
DLL SFLOG.dll
See also
SFLOG_INIT, SFLOG_INITA, SFLOG_INITW
References
Examples
log_ascii.cpp, log_init.cpp, and log_wchar.cpp.