Changeset 500
- Timestamp:
- Apr 21, 2004, 11:43:54 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
sys/psLogMsg.c (modified) (7 diffs)
-
sysUtils/psLogMsg.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psLogMsg.c
r499 r500 1 1 /***************************************************************************** 2 2 A simple implementation of a logging facility for Pan-STARRS 3 4 NOTES: currently, the prototype code has the following global variables: 5 static int logDest; 6 static int logLevel; 7 static int log_time; 8 static int log_host; 9 static int log_level; 10 static int log_name; 11 static int log_msg; 3 12 *****************************************************************************/ 4 13 #include <limits.h> … … 20 29 static int logDest = PS_LOG_TO_STDERR; // where to log messages 21 30 static int logLevel = PS_LOG_INFO; // log all messages at this or above 31 // The following variables control 32 // which information is displayed in 33 // log messages. 34 static int log_time = 1; // Flag to include time info 35 static int log_host = 1; // Flag to include host info 36 static int log_level = 1; // Flag to include level info 37 static int log_name = 1; // Flag to include name info 38 static int log_msg = 1; // Flag to include message info 22 39 /***************************************************************************** 23 40 psSetLogLevel(): Set the current log level and return old level. … … 33 50 int oldLevel = logLevel; 34 51 35 if ((level < MIN_LOG_LEVEL) || 36 (level > MAX_LOG_LEVEL)) { 52 if ((level < MIN_LOG_LEVEL) || (level > MAX_LOG_LEVEL)) { 37 53 psLogMsg("logmsg", PS_LOG_WARN, 38 54 "Attempt to set invalid logMsg level: %d", level); … … 47 63 /***************************************************************************** 48 64 psSetLogDestination(): sets the destination where log messages will be 49 sent to. 65 sent to. 66 50 67 Input: 51 68 dest (int): the new log destination … … 76 93 77 94 78 static int log_time = 1; 79 static int log_host = 1; 80 static int log_level = 1; 81 static int log_name = 1; 82 static int log_msg = 1; 83 /***************************************************************************** 84 psSetLogFormat(): Set the format of psLogMsg output. More precisely, 95 /***************************************************************************** 96 psSetLogFormat(): Set the format of psLogMsg output. More precisely, 85 97 provide a string consisting of the letters {H (host), L (level), M 86 98 (message), N (name), T (time)}. The default is "HLMNT". This string … … 88 100 included in message logs. It does not determine the order in which that 89 101 information will appear (that order is fixed). 90 Input: 91 fmt: a string specifying the format. 92 Output: 93 none. 94 Return: 95 NULL. 102 103 Input: 104 fmt: a string specifying the format. 105 Output: 106 none. 107 Return: 108 NULL. 96 109 *****************************************************************************/ 97 110 void psSetLogFormat(const char *fmt) … … 172 185 static int first = 1; 173 186 static char hostname[HOST_NAME_MAX + 1]; 174 char clevel=0; // letter-name for level175 char head[HOST_NAME_MAX + 40]; // yes, this is long enough176 char *head_ptr = head; // where we've got to in head187 char clevel=0; // letter-name for level 188 char head[HOST_NAME_MAX + 40]; // yes, this is long enough 189 char *head_ptr = head; // where we've got to in head 177 190 time_t clock = time(NULL); 178 191 struct tm *utc = gmtime(&clock); 179 192 180 if ((level > logLevel) || 181 (logDest == PS_LOG_NONE)) { 193 if ((level > logLevel) || (logDest == PS_LOG_NONE)) { 182 194 return; 183 195 } -
trunk/psLib/src/sysUtils/psLogMsg.c
r499 r500 1 1 /***************************************************************************** 2 2 A simple implementation of a logging facility for Pan-STARRS 3 4 NOTES: currently, the prototype code has the following global variables: 5 static int logDest; 6 static int logLevel; 7 static int log_time; 8 static int log_host; 9 static int log_level; 10 static int log_name; 11 static int log_msg; 3 12 *****************************************************************************/ 4 13 #include <limits.h> … … 20 29 static int logDest = PS_LOG_TO_STDERR; // where to log messages 21 30 static int logLevel = PS_LOG_INFO; // log all messages at this or above 31 // The following variables control 32 // which information is displayed in 33 // log messages. 34 static int log_time = 1; // Flag to include time info 35 static int log_host = 1; // Flag to include host info 36 static int log_level = 1; // Flag to include level info 37 static int log_name = 1; // Flag to include name info 38 static int log_msg = 1; // Flag to include message info 22 39 /***************************************************************************** 23 40 psSetLogLevel(): Set the current log level and return old level. … … 33 50 int oldLevel = logLevel; 34 51 35 if ((level < MIN_LOG_LEVEL) || 36 (level > MAX_LOG_LEVEL)) { 52 if ((level < MIN_LOG_LEVEL) || (level > MAX_LOG_LEVEL)) { 37 53 psLogMsg("logmsg", PS_LOG_WARN, 38 54 "Attempt to set invalid logMsg level: %d", level); … … 47 63 /***************************************************************************** 48 64 psSetLogDestination(): sets the destination where log messages will be 49 sent to. 65 sent to. 66 50 67 Input: 51 68 dest (int): the new log destination … … 76 93 77 94 78 static int log_time = 1; 79 static int log_host = 1; 80 static int log_level = 1; 81 static int log_name = 1; 82 static int log_msg = 1; 83 /***************************************************************************** 84 psSetLogFormat(): Set the format of psLogMsg output. More precisely, 95 /***************************************************************************** 96 psSetLogFormat(): Set the format of psLogMsg output. More precisely, 85 97 provide a string consisting of the letters {H (host), L (level), M 86 98 (message), N (name), T (time)}. The default is "HLMNT". This string … … 88 100 included in message logs. It does not determine the order in which that 89 101 information will appear (that order is fixed). 90 Input: 91 fmt: a string specifying the format. 92 Output: 93 none. 94 Return: 95 NULL. 102 103 Input: 104 fmt: a string specifying the format. 105 Output: 106 none. 107 Return: 108 NULL. 96 109 *****************************************************************************/ 97 110 void psSetLogFormat(const char *fmt) … … 172 185 static int first = 1; 173 186 static char hostname[HOST_NAME_MAX + 1]; 174 char clevel=0; // letter-name for level175 char head[HOST_NAME_MAX + 40]; // yes, this is long enough176 char *head_ptr = head; // where we've got to in head187 char clevel=0; // letter-name for level 188 char head[HOST_NAME_MAX + 40]; // yes, this is long enough 189 char *head_ptr = head; // where we've got to in head 177 190 time_t clock = time(NULL); 178 191 struct tm *utc = gmtime(&clock); 179 192 180 if ((level > logLevel) || 181 (logDest == PS_LOG_NONE)) { 193 if ((level > logLevel) || (logDest == PS_LOG_NONE)) { 182 194 return; 183 195 }
Note:
See TracChangeset
for help on using the changeset viewer.
