From: Florian G. <re...@us...> - 2007-12-09 20:40:43
|
Update of /cvsroot/perfparse/_perfparse/libpp_common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7457/libpp_common Modified Files: config_file.c libpp_common.h log.c Log Message: Add error log level and more purging data. Index: log.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/log.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** log.c 6 Jun 2007 09:53:14 -0000 1.3 --- log.c 9 Dec 2007 20:40:40 -0000 1.4 *************** *** 67,72 **** ! int pp_log (char *file, int line, int severity, char *fmt, ...) { va_list args; char message[LOG_MESSAGE_LENGTH]; --- 67,77 ---- ! int pp_log (char *file, int line, int log_level, char *fmt, ...) { + + if((log_level&config_get_value_as_integer(CONFIG_ITEM_ID_ERROR_LOG_LEVEL))==0) { + return; + } + va_list args; char message[LOG_MESSAGE_LENGTH]; *************** *** 83,86 **** --- 88,92 ---- pp_log_count++; + va_start (args, fmt); for (p = fmt; (p[0] != '\0') && (message_pos < LOG_MESSAGE_LENGTH); p++) *************** *** 142,148 **** fd = log_file_fopen(config_get_value_as_string(CONFIG_ITEM_ID_ERROR_LOG), t,config_get_value_as_boolean(CONFIG_ITEM_ID_ERROR_LOG_ROTATE)); if(!fd) fd = stderr; ! // todo: add option for severity in config #ifdef LOG_DEBUG_INFORMATION ! fprintf(fd, "%s [%12s:%-5d Pid: %-6ld severity: %d ] %s\n", log_date, file, line, (long)getpid(), severity, message); #else fprintf(fd, "%s [pid %-6ld] %s\n", log_date, (long)getpid(), message); --- 148,154 ---- fd = log_file_fopen(config_get_value_as_string(CONFIG_ITEM_ID_ERROR_LOG), t,config_get_value_as_boolean(CONFIG_ITEM_ID_ERROR_LOG_ROTATE)); if(!fd) fd = stderr; ! // todo: add option for log level in config #ifdef LOG_DEBUG_INFORMATION ! fprintf(fd, "%s [%12s:%-5d Pid: %-6ld log level: %d ] %s\n", log_date, file, line, (long)getpid(), log_level, message); #else fprintf(fd, "%s [pid %-6ld] %s\n", log_date, (long)getpid(), message); *************** *** 152,154 **** return (0); } - --- 158,159 ---- Index: libpp_common.h =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/libpp_common.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libpp_common.h 6 Jun 2007 09:53:14 -0000 1.6 --- libpp_common.h 9 Dec 2007 20:40:40 -0000 1.7 *************** *** 53,59 **** #define CONFIG_FILE "perfparse.cfg" ! #define LOG_DEBUG 10 ! #define LOG_INFO 4 ! #define LOG_WARNING 3 #define LOG_ERROR 2 #define LOG_CRITICAL 1 --- 53,66 ---- #define CONFIG_FILE "perfparse.cfg" ! #define LOG_DEBUG 4096 ! #define LOG_DEBUG7 2048 ! #define LOG_DEBUG6 1024 ! #define LOG_DEBUG5 256 ! #define LOG_DEBUG_SQL 128 ! #define LOG_DEBUG3 64 ! #define LOG_DEBUG2 32 ! #define LOG_DEBUG1 16 ! #define LOG_INFO 8 ! #define LOG_WARNING 4 #define LOG_ERROR 2 #define LOG_CRITICAL 1 *************** *** 79,82 **** --- 86,90 ---- CONFIG_ITEM_ID_CONFIG_FILE, CONFIG_ITEM_ID_ERROR_LOG, + CONFIG_ITEM_ID_ERROR_LOG_LEVEL, CONFIG_ITEM_ID_ERROR_LOG_ROTATE, CONFIG_ITEM_ID_ERROR_LOG_KEEP_N_DAYS, Index: config_file.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/config_file.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** config_file.c 9 Apr 2007 22:39:09 -0000 1.4 --- config_file.c 9 Dec 2007 20:40:40 -0000 1.5 *************** *** 107,110 **** --- 107,111 ---- config_item_add(config_definition, CONFIG_ITEM_ID_CONFIG_FILE, "Config_File", "/" SYSCONFDIR "/" CONFIG_FILE , _("Config file"), _("File for Perfparse configuration"), "-c", "--config-file", TYPE_STRING, 0); config_item_add(config_definition, CONFIG_ITEM_ID_ERROR_LOG, "Error_Log", default_error_log, _("Perfparse log"), _("File where Perfparse logs messages"), "-e", "--error-log", TYPE_STRING, 1); + config_item_add(config_definition, CONFIG_ITEM_ID_ERROR_LOG_LEVEL, "Error_Log_Level", "255", _("Perfparse log level"), _("Error log level"), NULL, "--error-log-level", TYPE_INT, 1); config_item_add(config_definition, CONFIG_ITEM_ID_ERROR_LOG_ROTATE, "Error_Log_Rotate", "yes", _("Perfparse log rotate"), _("Rotate Perfparse log files"), NULL, NULL,TYPE_BOOLEAN, 1); config_item_add(config_definition, CONFIG_ITEM_ID_ERROR_LOG_KEEP_N_DAYS, "Error_Log_Keep_N_Days", "7", _("Keep N days of error log"), _("Keep N days of error log. Compress recent logs and remove too old ones"), NULL, NULL,TYPE_INT, 1); |