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.1.1.1 $ $Name: $ 00014 * @date $Date: 2005/09/14 20:42:48 $ 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 * This procedure will take a character string as an 00030 * argument which can specify general log destinations. 00031 * 00032 * @return bool true if set successfully, otherwise false. 00033 */ 00034 bool psLogSetDestination( 00035 int fd ///< Specifies where to send messages. 00036 ); 00037 00038 /** This procedure sets the message level for future log messages. Subsequent 00039 * log messages, with a log level of "mylevel", will only be logged if 00040 * "mylevel" is less than the current log level set by this procedure. 00041 * Ie. higher values set by this procedure will cause more log messages to 00042 * be displayed. The old log level will be returned. 00043 * 00044 * @return int old logging level 00045 */ 00046 int psLogSetLevel( 00047 int level ///< Specifies the system log level 00048 ); 00049 00050 /** This procedure sets the log format for future log messages. The argument 00051 * must be a character string consistsing of the letters H (host), L 00052 * (level), M (message), N (name), and T (time). The default is "THLNM". 00053 * Deleting a letter from the string will cause the associated information 00054 * to not be logged. This procedure does not alter the order in which 00055 * the messages are displayed. 00056 * 00057 * @return bool: True if successful, otherwise false. 00058 */ 00059 bool psLogSetFormat( 00060 const char *format ///< Specifies the system log format 00061 ); 00062 00063 /** This procedures uses a string to set the destination for which to send 00064 * the corresponding log messages. 00065 * 00066 * 00067 * @return int: The file descriptor location of the message. 00068 */ 00069 int psMessageDestination( 00070 const char *dest ///< Specifies where to send the message 00071 ); 00072 00073 /** This procedure logs a message to the destination set by a prior 00074 * call to psLogSetDestination(), if myLevel is less than the level 00075 * specified by a prior call to psLogSetLevel(). The message is specified 00076 * with a printf-type string and arguments. 00077 * 00078 */ 00079 void psLogMsg( 00080 const char *name, ///< name of the log source 00081 int level, ///< severity level of this log message 00082 const char *format, ///< printf-style format command 00083 ... 00084 ); 00085 00086 #ifndef SWIG 00087 /** This procedure is functionally equivalent to psLogMsg(), except that 00088 * it takes a va_list as the message parameter, not a printf-style string. 00089 * 00090 */ 00091 void psLogMsgV( 00092 const char *name, ///< name of the log source 00093 int level, ///< severity level of this log message 00094 const char *format, ///< printf-style format command 00095 va_list ap ///< varargs argument list 00096 ); 00097 #endif // #ifndef SWIG 00098 00099 ///< Status codes for log messages 00100 enum { 00101 PS_LOG_ABORT = 0, ///< log message is a critical error, perform an abort after printing 00102 PS_LOG_ERROR, ///< log message is an error, but don't abort 00103 PS_LOG_WARN, ///< log message is a warning 00104 PS_LOG_INFO ///< log message is informational only 00105 }; 00106 00107 ///< Destinations for log messages 00108 enum { 00109 PS_LOG_NONE, ///< turn off logging 00110 PS_LOG_TO_STDERR, ///< log to system's stderr 00111 PS_LOG_TO_STDOUT ///< log to system's stdout 00112 }; 00113 00114 /// @} 00115 00116 #endif // #ifndef PS_LOG_MSG_H
1.4.2