Y2Logger.h

Go to the documentation of this file.
00001 /* Y2Logger.h
00002  *
00003  * Macros for logging the output.
00004  *
00005  * Just #include "Y2Logger.h" and use Y2_DEBUG, Y2_WARNING or Y2_ERROR
00006  * 
00007  * If you write Y2_DEBUG("Hello: %d",7) on line 13 in the file Source.cc,
00008  * the debug output will look like this:
00009  *   [...]:Source.cc[13] Hello: 7
00010  *
00011  * Additionally you can #define Y2_COMPONENT before inclusion and its name
00012  * will be put just before the Source.cc.
00013  * And don't forget set (end export the Y2DEBUG shell variable!
00014  *
00015  * Also define Y2_DEBUG_YES if you want to get the debugging output!
00016  *
00017  * Author: Michal Svec <msvec@suse.cz>
00018  *         Daniel Vesely <dan@suse.cz>
00019  *
00020  * $Id: Y2Logger.h 9684 2003-04-02 12:53:31Z jsrain $
00021  */
00022 
00023 #ifndef Y2Logger_h
00024 #define Y2Logger_h
00025 
00026 #define y2log_component "ag_ppd"
00027 #include <ycp/y2log.h>
00028 
00029 //FIXME:
00030 #define Y2_DEBUG_YES 1
00031 
00032 extern char last_error[1024];
00033 
00034 /*
00035  * Logging macros
00036  */
00037 #ifndef Y2_DEBUG_YES
00038 #define Y2_DEBUG(format,args...)
00039 #else
00040 #define Y2_DEBUG(format,args...) \
00041     y2debug(format,##args)
00042 #endif
00043 
00044 #define Y2_WARNING(format,args...) \
00045     y2warning(format,##args)
00046 
00047 #define Y2_ERROR(format,args...) \
00048     {\
00049     y2error(format,##args);\
00050     snprintf (last_error,1023,format,##args);\
00051     }
00052 
00053 /*
00054  * Log the error and return ...
00055  */
00056 #define Y2_RETURN_FALSE(format,args...) \
00057   { y2error(format,##args); return false; }
00058 
00059 #define Y2_RETURN_VOID(format,args...) \
00060   { y2error(format,##args); return YCPVoid(); }
00061 
00062 #define Y2_RETURN_STR(format,args...) \
00063   { y2error(format,##args); return ""; }
00064 
00065 #define Y2_RETURN_YCP_FALSE(format,args...) \
00066   { y2error(format,##args); return YCPBoolean(false); }
00067 
00068 #endif /* Y2Logger_h */

Generated on Fri May 18 11:43:15 2007 for yast2-printer by  doxygen 1.4.6