The log functions are used internally to display debug information, messages, warnings and errors. The log functions can also come in handy outside libdicom.
The variable dicom_log_level controls what messages are logged. It can be set to one of the following values:
For example, if you set dicom_log_level to CRITICAL you will only see messages from conditions that are at least critical. The default level is INFO.
Use this function if you want your program name to show up in the log. If this function is not called, "log" will be used as default program name. If you pass a filename, only the basename will be used.
Example:
dicom_log_name(*argv);
Use this function if you want the log to be written to a file. This function will attempt to open the filename given and append the log to it. If it succeeds it will return 0. If not, logging continues on the default stream stderr.
Use this function to add a message to the log. CONDITION is one of the conditions declared in the previous section. The message will show up in the following format:
Date Time ProgramName[ProcessID]: Condition: Message
Example:
Oct 17 12:45:42 xrad[19401]: error: Unable to open file
This function closes the file you opened with dicom_log_open(). If it succeeds it will return 0. If not, logging is continued on the default stream stderr.
In most cases, you only call dicom_log_name(*argv) from your main() function, and dicom_log() whenever you want a message logged.
typedef enum { EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG } CONDITION; extern CONDITION dicom_log_level; void dicom_log_name(char *); int dicom_log_open(const char *); void dicom_log(CONDITION,const char *); int dicom_log_close(void);