From: Florian G. <re...@us...> - 2007-06-06 09:53:16
|
Update of /cvsroot/perfparse/_perfparse/libpp_common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29306/libpp_common Modified Files: clean_tools.c libpp_common.h log.c Log Message: enhance error logging Index: log.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/log.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** log.c 24 Aug 2006 14:36:45 -0000 1.2 --- log.c 6 Jun 2007 09:53:14 -0000 1.3 *************** *** 3,7 **** * log.c - API to the config file used by PerfParse suit. * ! * Copyright (c) 2004 Yves Mettier <yme...@li...> * * $Id$ --- 3,8 ---- * log.c - API to the config file used by PerfParse suit. * ! * Copyright (c) 2004-2007 Yves Mettier <yme...@li...> ! * Florian Gleixner * * $Id$ *************** *** 66,70 **** ! int pp_log (char *file, int line, char *fmt, ...) { va_list args; --- 67,71 ---- ! int pp_log (char *file, int line, int severity, char *fmt, ...) { va_list args; *************** *** 141,146 **** 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; #ifdef LOG_DEBUG_INFORMATION ! fprintf(fd, "%s [%12s:%-5d %-6ld] %s\n", log_date, file, line, (long)getpid(), message); #else fprintf(fd, "%s [pid %-6ld] %s\n", log_date, (long)getpid(), message); --- 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); Index: libpp_common.h =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/libpp_common.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libpp_common.h 24 Aug 2006 14:36:45 -0000 1.5 --- libpp_common.h 6 Jun 2007 09:53:14 -0000 1.6 *************** *** 3,7 **** * libpp_common.h - API to the config file used by PerfParse suit. * ! * Copyright (c) 2004 Yves Mettier <yme...@li...> * * $Id$ --- 3,8 ---- * libpp_common.h - API to the config file used by PerfParse suit. * ! * Copyright (c) 2004-2007 Yves Mettier <yme...@li...> ! * Florian Gleixner * * $Id$ *************** *** 52,57 **** #define CONFIG_FILE "perfparse.cfg" FILE* log_file_fopen(char*name, time_t tm, int rotate); ! int pp_log (char *file, int line, char *fmt, ...); extern char *pp_log_file; extern int pp_log_count; --- 53,65 ---- #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 + #define LOG_FATAL 1 + FILE* log_file_fopen(char*name, time_t tm, int rotate); ! int pp_log (char *file, int line, int severity, char *fmt, ...); extern char *pp_log_file; extern int pp_log_count; Index: clean_tools.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_common/clean_tools.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** clean_tools.c 28 Oct 2006 19:52:29 -0000 1.3 --- clean_tools.c 6 Jun 2007 09:53:14 -0000 1.4 *************** *** 3,7 **** * clean_tools.c - Logfile compression/rotation. * ! * Copyright (c) 2004 Yves Mettier (yme...@li...) * * $Id$ --- 3,8 ---- * clean_tools.c - Logfile compression/rotation. * ! * Copyright (c) 2004-2007 Yves Mettier (yme...@li...) ! * Florian Gleixner * * $Id$ *************** *** 49,53 **** if(-1 == (fd = open(name, O_RDONLY))) { ! pp_log(__FILE__,__LINE__, _("Could not open file '%s'"), name); l = -1; } else { --- 50,54 ---- if(-1 == (fd = open(name, O_RDONLY))) { ! pp_log(__FILE__,__LINE__,LOG_WARNING, _("Could not open file '%s'"), name); l = -1; } else { *************** *** 65,74 **** unlink(name); } else if(l == -1) { ! pp_log(__FILE__,__LINE__, _("An error occured while reading file '%s' (%s)"), name, strerror(errno)); unlink(name_gz); } else if(l == -2) { ! pp_log(__FILE__,__LINE__, _("An error occured while writing file '%s'"), name_gz); } else { ! pp_log(__FILE__,__LINE__, _("An error occured while compressing file '%s'. This should not occur. This is a bug. Please report it to the development team. (l=%d)"), name_gz,l); l = -3; } --- 66,75 ---- unlink(name); } else if(l == -1) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("An error occured while reading file '%s' (%s)"), name, strerror(errno)); unlink(name_gz); } else if(l == -2) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("An error occured while writing file '%s'"), name_gz); } else { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("An error occured while compressing file '%s'. This should not occur. This is a bug. Please report it to the development team. (l=%d)"), name_gz,l); l = -3; } *************** *** 100,104 **** if(NULL == (dh = opendir(path))) { ! pp_log(__FILE__,__LINE__, _("Could not open directory '%s'"), path); return(-1); } --- 101,105 ---- if(NULL == (dh = opendir(path))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("Could not open directory '%s'"), path); return(-1); } |