00001 /** @file psLogMsg.h 00002 * @brief Procedures for logging messages. 00003 * \ingroup LogTrace 00004 * 00005 * This file will hold the prototypes for defining procedure which set 00006 * message log levels, messahe log formats, message log destinations, and 00007 * for generating the messages themselves. 00008 * @ingroup LogTrace 00009 * 00010 * @author Robert Lupton, Princeton University 00011 * @author GLG, MHPCC 00012 * 00013 * @version $Revision: 1.35 $ $Name: rel12 $ 00014 * @date $Date: 2006/06/16 23:01:10 $ 00015 * 00016 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00017 */ 00018 #ifndef PS_LOG_MSG_H 00019 #define PS_LOG_MSG_H 00020 #include <stdarg.h> 00021 00022 #include "psType.h" 00023 00024 /** @addtogroup LogTrace 00025 * @{ 00026 */ 00027 00028 /** This procedure sets the destination for future log messages. 00029 * 00030 * This procedure will take an integer as an argument 00031 * which can specify general log destinations. 00032 * 00033 * @return bool true if set successfully, otherwise false. 00034 */ 00035 bool psLogSetDestination( 00036 int fd ///< Specifies where to send messages. 00037 ); 00038 00039 /** This procedure returns the current log destination file descriptor. If the 00040 * destination has not been defined by the use, the descriptor for stdout is returned. 00041 * 00042 * @return int: The current file descriptor. 00043 */ 00044 int psLogGetDestination(); 00045 00046 /** This procedure sets the message level for future log messages. Subsequent 00047 * log messages, with a log level of "mylevel", will only be logged if 00048 * "mylevel" is less than the current log level set by this procedure. 00049 * Ie. higher values set by this procedure will cause more log messages to 00050 * be displayed. The old log level will be returned. 00051 * 00052 * @return int: old logging level. 00053 */ 00054 int psLogSetLevel( 00055 int level ///< Specifies the system log level 00056 ); 00057 00058 /** This procedures returns the current log message level. 00059 * 00060 * @return int: The current logging level. 00061 */ 00062 int psLogGetLevel(); 00063 00064 /** This procedure sets the log format for future log messages. The argument 00065 * must be a character string consistsing of the letters H (host), L 00066 * (level), M (message), N (name), and T (time). The default is "THLNM". 00067 * Deleting a letter from the string will cause the associated information 00068 * to not be logged. This procedure does not alter the order in which 00069 * the messages are displayed. 00070 * 00071 * @return bool: True if successful, otherwise false. 00072 */ 00073 bool psLogSetFormat( 00074 const char *format ///< Specifies the system log format 00075 ); 00076 00077 /** This procedures uses a string to set the destination for which to send 00078 * the corresponding log messages. 00079 * 00080 * @return int: The file descriptor location of the message. 00081 */ 00082 int psMessageDestination( 00083 const char *dest ///< Specifies where to send the message 00084 ); 00085 00086 /** This procedure logs a message to the destination set by a prior 00087 * call to psLogSetDestination(), if myLevel is less than the level 00088 * specified by a prior call to psLogSetLevel(). The message is specified 00089 * with a printf-type string and arguments. 00090 * 00091 */ 00092 void psLogMsg( 00093 const char *name, ///< name of the log source 00094 int level, ///< severity level of this log message 00095 const char *format, ///< printf-style format command 00096 ... 00097 ); 00098 00099 #ifndef SWIG 00100 /** This procedure is functionally equivalent to psLogMsg(), except that 00101 * it takes a va_list as the message parameter, not a printf-style string. 00102 * 00103 */ 00104 void psLogMsgV( 00105 const char *name, ///< name of the log source 00106 int level, ///< severity level of this log message 00107 const char *format, ///< printf-style format command 00108 va_list ap ///< varargs argument list 00109 ); 00110 #endif // #ifndef SWIG 00111 00112 ///< Status codes for log messages 00113 enum { 00114 PS_LOG_ABORT = 0, ///< log message is a critical error, perform an abort after printing 00115 PS_LOG_ERROR, ///< log message is an error, but don't abort 00116 PS_LOG_WARN, ///< log message is a warning 00117 PS_LOG_INFO ///< log message is informational only 00118 }; 00119 00120 ///< Destinations for log messages 00121 enum { 00122 PS_LOG_TO_NONE = 0, ///< turn off logging 00123 PS_LOG_TO_STDERR = 1, ///< log to system's stderr 00124 PS_LOG_TO_STDOUT = 2 ///< log to system's stdout 00125 }; 00126 00127 /// @} 00128 00129 #endif // #ifndef PS_LOG_MSG_H
1.4.4