LJM Debug Logger Configs
The LJM debug logger can output debug information to a file.
Relevant Functions
To read the debug logger configurations, use LJM_ReadLibraryConfigStringS.
To write the debug logger configurations, use LJM_WriteLibraryConfigStringS or LJM_LoadConfigurationFile.
For more information, see Debugging Functions.
For more LJM configurations, see Library Configuration Functions.
LJM_DEBUG_LOG_FILE
Default
Windows Vista and later:
C:\ProgramData\LabJack\LJM\ljm.log
Windows XP:
C:\Documents and Settings\All Users\Application Data\LabJack\LJM\ljm.log
Mac OS X and Linux:
/usr/local/share/LabJack/LJM/ljm.log
Summary
LJM_DEBUG_LOG_FILE
is a string-based readable-writable LJM library configuration which sets the absolute or relative path of the file to output log messages to.
The constant LJM_DEBUG_LOG_FILE
can be used interchangeably with the string "LJM_DEBUG_LOG_FILE"
.
Details
The configuration value of LJM_DEBUG_LOG_FILE
is meaningless if LJM_DEBUG_LOG_MODE
is in LJM_DEBUG_LOG_MODE_NEVER
(which is the default).
Relevant Constants
See the debug logger parameters, especially LJM_DEBUG_LOG_MODE
.
Example
Set LJM to log to the log file "ljm_monday.log"
char ErrorString[LJM_MAX_NAME_SIZE];
char DebugLogFile[LJM_MAX_NAME_SIZE];
int LJMError;
printf("Setting LJM_DEBUG_LOG_MODE to LJM_DEBUG_LOG_MODE_CONTINUOUS\n");
LJMError = LJM_WriteLibraryConfigS(LJM_DEBUG_LOG_MODE, LJM_DEBUG_LOG_MODE_CONTINUOUS);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_WriteLibraryConfigS error: %s\n", ErrorString);
}
printf("Setting LJM_DEBUG_LOG_FILE to ljm_monday.log\n");
LJMError = LJM_WriteLibraryConfigStringS(LJM_DEBUG_LOG_FILE, "ljm_monday.log");
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_WriteLibraryConfigStringS error: %s\n", ErrorString);
}
LJMError = LJM_ReadLibraryConfigStringS(LJM_DEBUG_LOG_FILE, DebugLogFile);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_ReadLibraryConfigStringS error: %s\n", ErrorString);
}
printf("LJM_DEBUG_LOG_FILE is now %s\n", DebugLogFile);
Possible output:
Setting LJM_DEBUG_LOG_MODE to LJM_DEBUG_LOG_MODE_CONTINUOUS
Setting LJM_DEBUG_LOG_FILE to ljm_monday.log
LJM_DEBUG_LOG_FILE is now ljm_monday.log
LJM_DEBUG_LOG_FILE_MAX_SIZE
LJM_DEBUG_LOG_FILE_MAX_SIZE
is a numerical readable-writable LJM library configuration that limits the number of characters in the debug log file. Once the debug log file has exceeded LJM_DEBUG_LOG_FILE_MAX_SIZE
characters, it will be reset to 0 characters and debug logging will continue. The largest LJM_DEBUG_LOG_FILE_MAX_SIZE
you may use is the largest file size of your operating system. The default is 50000 characters.
The constant LJM_DEBUG_LOG_FILE_MAX_SIZE
can be used interchangeably with the string "LJM_DEBUG_LOG_FILE_MAX_SIZE"
.
Example
Set LJM_DEBUG_LOG_FILE_MAX_SIZE to a larger-than-default size
char ErrorString[LJM_MAX_NAME_SIZE];
int LJMError;
LJMError = LJM_WriteLibraryConfigS(LJM_DEBUG_LOG_FILE_MAX_SIZE, 123456789);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_WriteLibraryConfigS error: %s\n", ErrorString);
}
For more LJM configurations, see Library Configuration Functions.
LJM_DEBUG_LOG_LEVEL
LJM_DEBUG_LOG_LEVEL
is a numerical readable-writable LJM library configuration with the following options:
LJM_STREAM_PACKET = 1
LJM_TRACE = 2
LJM_DEBUG = 4
LJM_INFO = 6
LJM_PACKET = 7
LJM_WARNING = 8
LJM_USER = 9
LJM_ERROR = 10
LJM_FATAL = 12
The constant LJM_DEBUG_LOG_LEVEL
can be used interchangeably with the string "LJM_DEBUG_LOG_LEVEL"
.
Details
LJM_DEBUG_LOG_MODE
must allow for logging in order for LJM_DEBUG_LOG_LEVEL
to have any effect.
LJM_DEBUG_LOG_LEVEL
determines which log messages are output. LJM outputs the debug messages that are of the current LJM_DEBUG_LOG_LEVEL
and greater.
Example
Read LJM_DEBUG_LOG_LEVEL then set LJM_DEBUG_LOG_LEVEL to LJM_WARNING
char ErrorString[LJM_MAX_NAME_SIZE];
double value;
int LJMError = LJM_ReadLibraryConfigS(LJM_DEBUG_LOG_LEVEL, &value);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_ReadLibraryConfigS error: %s\n", ErrorString);
}
printf("The default for LJM_DEBUG_LOG_LEVEL is %.00f\n", value);
value = LJM_WARNING;
printf("Setting LJM_DEBUG_LOG_LEVEL to %.00f\n", value);
LJMError = LJM_WriteLibraryConfigS(LJM_DEBUG_LOG_LEVEL, value);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_DEBUG_LOG_LEVEL error: %s\n", ErrorString);
}
Possible output:
The default for LJM_DEBUG_LOG_LEVEL is 7
Setting LJM_DEBUG_LOG_LEVEL to 8
LJM_DEBUG_LOG_MODE
LJM_DEBUG_LOG_MODE
is a numerical readable-writable LJM library configuration with the following options:
LJM_DEBUG_LOG_MODE_NEVER = 1
LJM will never log messages
The log thread will never start
LJM_DEBUG_LOG_MODE_CONTINUOUS = 2
LJM will log all messages with priority equal to or greater than the current
LJM_DEBUG_LOG_LEVEL
The log thread will start when the first message with priority equal to or greater than the current
LJM_DEBUG_LOG_LEVEL
is scheduled to be output
LJM_DEBUG_LOG_MODE_ON_ERROR = 3
LJM will collect all messages with priority equal to or greater than the current
LJM_DEBUG_LOG_LEVEL
, but only output those messages if a log message with priority equal to or greater thanLJM_ERROR
(10) is scheduled to be outputThe maximum number of messages that will be collected is
LJM_DEBUG_LOG_BUFFER_MAX_SIZE
The log thread will start when the first message with priority equal to or greater than the current
LJM_DEBUG_LOG_LEVEL
is scheduled to be output
The constant LJM_DEBUG_LOG_MODE
can be used interchangeably with the string "LJM_DEBUG_LOG_MODE"
.
Example
Read LJM_DEBUG_LOG_MODE, set LJM_DEBUG_LOG_MODE, then read it again
char ErrorString[LJM_MAX_NAME_SIZE];
double Value = 0;
int LJMError = LJM_ReadLibraryConfigS(LJM_DEBUG_LOG_MODE, &Value);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_ReadLibraryConfigS error: %s\n", ErrorString);
}
printf("The default for LJM_DEBUG_LOG_MODE is %.00f\n", Value);
Value = LJM_DEBUG_LOG_MODE_CONTINUOUS;
printf("Setting LJM_DEBUG_LOG_MODE to %.00f\n", Value);
LJMError = LJM_WriteLibraryConfigS(LJM_DEBUG_LOG_MODE, Value);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_WriteLibraryConfigS error: %s\n", ErrorString);
}
LJMError = LJM_ReadLibraryConfigS(LJM_DEBUG_LOG_MODE, &Value);
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_ReadLibraryConfigS error: %s\n", ErrorString);
}
printf("LJM_DEBUG_LOG_MODE is now %.00f\n", Value);
Possible output:
The default for LJM_DEBUG_LOG_MODE is 1
Setting LJM_DEBUG_LOG_MODE to 2
LJM_DEBUG_LOG_MODE is now 2
LJM_DEBUG_LOG_BUFFER_MAX_SIZE
LJM_DEBUG_LOG_BUFFER_MAX_SIZE
is a numerical readable-writeable LJM library configuration that sets how many messages the log buffer can hold.
Default Value: 4000
LJM_DEBUG_LOG_SLEEP_TIME_MS
LJM_DEBUG_LOG_SLEEP_TIME_MS
is a numerical readable-writeable LJM Library configuration that sets how often the logger thread will run.
Default Value: 20